简体   繁体   English

如何使用Oracle的apex_json从返回的JSON对象获取odata.nextLink

[英]How to get odata.nextLink from the returned JSON object using oracle's apex_json

I am retrieving data from an odata service. 我正在从odata服务中检索数据。 The response contains a link for loading more data ie odata.nextLink which I need to retrieve to load more data. 响应包含一个用于加载更多数据的链接,即odata.nextLink,我需要检索该链接才能加载更多数据。 How do I do this using oracle's apex_json? 如何使用oracle的apex_json执行此操作? The server's response is something like this: 服务器的响应是这样的:

{
  "odata.metadata":"http://localhost:60497/odata/$metadata#tables","value":[
    {"id":001,"name":"abc" }

      .
      .
  ],
"odata.nextLink":"http://localhost:60497/odata/tables?$skip=10"
}

Normally I would parse the data and then retrieve the information like this next_link := apex_json.get_varchar2('odata.nextLink'); 通常,我会解析数据,然后检索类似next_link := apex_json.get_varchar2('odata.nextLink');的信息next_link := apex_json.get_varchar2('odata.nextLink'); but since it contains a point that won't work. 但由于它包含的点无效。

In this case: 在这种情况下:

apex_json.get_varchar2('odata.nextLink');

it is considering nextLink as the value of odata. 它正在考虑将nextLink作为odata的值。

DECLARE

v_json APEX_JSON.T_VALUES;
v_str_json VARCHAR2(4000);
next_link VARCHAR2(4000);

BEGIN


v_str_json := '{
  "odata" : {"nextLink" : "mylink"},
  "odata.metadata":"http://localhost:60497/odata/$metadata#tables","value":[
    {"id":001,"name":"abc" }
  ],
"odata.nextLink":"http://localhost:60497/odata/tables?$skip=10"
}
}';

APEX_JSON.PARSE(v_json, v_str_json);

next_link := APEX_JSON.GET_VARCHAR2(p_path => 'odata.nextLink', p_values => v_json);

dbms_output.put_line(next_link);

END;

>> OUTPUT: mylink
  • I do not know how to say "odata.nextLink" to be interpreted literally; 我不知道怎么说“ odata.nextLink”来进行字面解释。 and not as a path. 而不是一条路。

If nobody knows: 如果没人知道:

1 - or stop sending "odata." 1-或停止发送“ odata”。 at the beginning of the name of each attribute; 每个属性名称的开头;

2 - or use replace to remove. 2-或使用替换删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM