问题描述
示例JSON:
我试图利用pljson:
我能够提取,我不知道也许位置或地址值从这个JSON,但当我想提取元素term-id或bank-id我得到错误PL/SQL ORA-30625: 方法调度空自参数是不允许的。也许是因为 “-” 之间的标志?
谢谢。
[
{
"term-id": "BA000000",
"bank-id": "111",
"location": "Poslovalnica banke",
"address": "Cankarjeva ulica 2",
"city": "Ljubljana",
"post-code": "1000",
"printer": "true",
"deposit": "false",
"accessible": "true",
"cards": "DECPVR",
"special-payments": "false",
"BNA": "false",
"transaction-receipt": "true",
"latitude": 46.051671,
"longitude": 14.505122
}
]我试图利用pljson:
declare
w_req t_http_request := t_http_request();
w_res t_http_response;
w_vrni clob;
w_json pljson;
w_jsonValue pljson_value;
w_jsonList pljson_list;
w_test varchar2(100);
begin
w_req.url := 'https://api.bankart.si/psd2/hub/v1/' || 'ATMList';
w_req.add_header('x-ibm-client-id', 'client-id');
w_res := https_client.doGet (w_req, 'DB');
w_vrni := hibis_util.convertBlobToClob(w_res.content_blob,'AL32UTF8');
w_jsonList := pljson_list(w_vrni);
if w_jsonList is not null and w_jsonList.count > 0 then
for i in 1..w_jsonList.count loop
w_json := pljson(w_jsonList.get(i));
w_jsonValue := w_json.get('term-id');
w_test := w_jsonValue.get_string;
dopl(w_test);
end loop;
end if;
end;我能够提取,我不知道也许位置或地址值从这个JSON,但当我想提取元素term-id或bank-id我得到错误PL/SQL ORA-30625: 方法调度空自参数是不允许的。也许是因为 “-” 之间的标志?
谢谢。
专家解答
我不熟悉PL/JSON,但我怀疑问题出在这里:
for i in 1..w_jsonList.count loop
JSON数组是零索引的,因此第一项位于位置零。这从位置1开始搜索。您需要更改循环的开始和结束值:
for i in 0..w_jsonList.count - 1 loop
以下是使用12.2中添加的PL/SQL对象类型的示例:
for i in 1..w_jsonList.count loop
JSON数组是零索引的,因此第一项位于位置零。这从位置1开始搜索。您需要更改循环的开始和结束值:
for i in 0..w_jsonList.count - 1 loop
以下是使用12.2中添加的PL/SQL对象类型的示例:
declare
doc json_array_t;
item json_element_t;
begin
doc := json_array_t.parse ( '[
{
"term-id": "BA000000",
"bank-id": "111",
"location": "Poslovalnica banke",
"address": "Cankarjeva ulica 2",
"city": "Ljubljana",
"post-code": "1000",
"printer": "true",
"deposit": "false",
"accessible": "true",
"cards": "DECPVR",
"special-payments": "false",
"BNA": "false",
"transaction-receipt": "true",
"latitude": 46.051671,
"longitude": 14.505122
}
]' );
for i in 1 .. doc.get_size loop
item := doc.get ( i );
dbms_output.put_line ( treat ( item as json_object_t ).get ( 'term-id' ).to_String );
end loop;
end;
/
ORA-30625: method dispatch on NULL SELF argument is disallowed
declare
doc json_array_t;
item json_element_t;
begin
doc := json_array_t.parse ( '[
{
"term-id": "BA000000",
"bank-id": "111",
"location": "Poslovalnica banke",
"address": "Cankarjeva ulica 2",
"city": "Ljubljana",
"post-code": "1000",
"printer": "true",
"deposit": "false",
"accessible": "true",
"cards": "DECPVR",
"special-payments": "false",
"BNA": "false",
"transaction-receipt": "true",
"latitude": 46.051671,
"longitude": 14.505122
}
]' );
for i in 0 .. doc.get_size - 1 loop
item := doc.get ( i );
dbms_output.put_line ( treat ( item as json_object_t ).get ( 'term-id' ).to_String );
end loop;
end;
/
"BA000000" 文章转载自ASKTOM,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




