【问题标题】:JSON - PL/SQL ORA-30625: method dispatch on NULL SELF argument is disallowedJSON - PL/SQL ORA-30625:不允许对 NULL SELF 参数进行方法调度
【发布时间】:2020-11-13 01:16:27
【问题描述】:

示例 JSON:

[
  {
    "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: method dispatch不允许使用 NULL SELF 参数。也许是因为“-”之间的符号?

有人有想法吗?谢谢。

【问题讨论】:

  • 您正试图在一个为空的对象变量上调用方法。我怀疑它可能是 w_jsonValue 变量。

标签: json plsql


【解决方案1】:

我认为你把它弄得太复杂了。 :) 试试:

set serveroutput on
declare
   v_json pljson;
   v_test varchar2(100);
   v_jsonl pljson_list := pljson_list('[
  {
    "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
  }
]');
begin
   for i in 1..v_jsonl.count loop
      v_json := pljson(v_jsonl.get(i));
      v_test := v_json.get('term-id').get_string;
      dbms_output.put_line(v_test);
   end loop;
end;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多