解析要在Apex项目选择列表中使用的JSON对象

时间:2015-09-16 08:54:09

标签: json oracle-apex

我正在尝试将JSON对象解析为APEX选择列表。有一些方法可以解析JSON对象,但我还没有遇到或想出一种方法来解析JSON对象并将其用作Apex应用程序中的选择列表。大多数问题都是从Apex数据生成JSON。任何帮助,将不胜感激。谢谢!

我要解析的数据(更简单的例子)如下:

    {
  "verumModelObjectName": "Address",
  "verumObjectList": [
    {
      "locationID": "20005",
      "country": "ARE"
    },
    {
      "locationID": "31083",
      "country": "ARE"
    },
    {
      "locationID": "31118",
      "country": "ARE"
    },
    {
      "locationID": "32185",
      "country": "ARE"
    },
    {
      "locationID": "32138",
      "country": "ARE"
    },
    {
      "locationID": "32070",
      "country": "ARE"
    },
    {
      "locationID": "32094",
      "country": "ARE"
    },
    {
      "locationID": "20006",
      "country": "ARG"
    },
    {
      "locationID": "32196",
      "country": "ARG"
    },
    {
      "locationID": "41057",
      "country": "ARG"
    },
    {
      "locationID": "31032",
      "country": "ARG"
    },
    {
      "locationID": "33212",
      "country": "ARG"
    },
    {
      "locationID": "3558",
      "country": "ARG"
    },
    {
      "locationID": "33126",
      "country": "ARG"
    },
    {
      "locationID": "31007",
      "country": "ARG"
    },
    {
      "locationID": "33127",
      "country": "ARG"
    },
    {
      "locationID": "31100",
      "country": "ASM"
    },
    {
      "locationID": "20008",
      "country": "AUS"
    },
    {
      "locationID": "20591",
      "country": "AUS"
    },
    {
      "locationID": "31125",
      "country": "AUS"
    }]
  "statusCode": 200
}

1 个答案:

答案 0 :(得分:0)

你在5.0中检查了apex_json包吗? https://docs.oracle.com/cd/E59726_01/doc.50/e39149/apex_json.htm#AEAPI29640

您可以使用此程序包解析数据 然后对于选择列表,你应该创建一个带有d显示和r返回值的动态选择列表,如下所示。它应该工作

 select col1 d, col2 r
from xmltable (
        '/json/verumObjectList/row'
        passing apex_json.to_xmltype('

    {
  "verumModelObjectName": "Address",
  "verumObjectList": [
    {
      "locationID": "20005",
      "country": "ARE"
    },
    {
      "locationID": "31083",
      "country": "ARE"
    },
    {
      "locationID": "31118",
      "country": "ARE"
    },
    {
      "locationID": "32185",
      "country": "ARE"
    },
    {
      "locationID": "32138",
      "country": "ARE"
    },
    {
      "locationID": "32070",
      "country": "ARE"
    },
    {
      "locationID": "32094",
      "country": "ARE"
    },
    {
      "locationID": "20006",
      "country": "ARG"
    },
    {
      "locationID": "32196",
      "country": "ARG"
    },
    {
      "locationID": "41057",
      "country": "ARG"
    },
    {
      "locationID": "31032",
      "country": "ARG"
    },
    {
      "locationID": "33212",
      "country": "ARG"
    },
    {
      "locationID": "3558",
      "country": "ARG"
    },
    {
      "locationID": "33126",
      "country": "ARG"
    },
    {
      "locationID": "31007",
      "country": "ARG"
    },
    {
      "locationID": "33127",
      "country": "ARG"
    },
    {
      "locationID": "31100",
      "country": "ASM"
    },
    {
      "locationID": "20008",
      "country": "AUS"
    },
    {
      "locationID": "20591",
      "country": "AUS"
    },
    {
      "locationID": "31125",
      "country": "AUS"
    }],
  "statusCode": 200
}


')
        columns
           col1 number path '/row/locationID',
           col2 varchar2(5) path '/row/country' );