Oracle使用PLJSON读取JSON_LIST的JSON_LIST

时间:2016-05-03 11:34:06

标签: plsql oracle11g pljson

我正在尝试使用嵌套列表读取JSON对象。看起来像这样:

[{
    "id": 70070037001,
    "text": "List 1",
    "isleaf": 0,
    "children": [
        {
            "oid": 100,
            "text": "Innerlistobject100",
            "isleaf": 0,
            "children": [
                {
                    "sid": 1000,
                    "text": "Innerlistobject1000",
                    "isleaf": 1
                },
                {
                    "sid": 2000,
                    "text": "Innerlistobject2000",
                    "isleaf": 1
                }
            ]
        },
        {
            "oid": 200,
            "text": "Innerlistobject200",
            "isleaf": 0,
            "children": [
                {
                    "sid": 1000,
                    "text": "Innerlistobject1000",
                    "isleaf": 1
                },
                {
                    "sid": 2000,
                    "text": "Innerlistobject2000",
                    "isleaf": 1
                }
            ]
        }
    ]
}]

ref:https://sourceforge.net/p/pljson/discussion/935365/thread/375c0293/ - 此人正在创建对象,但我想反过来阅读它。

我是否必须像这样迭代(注意名字是儿童中的孩子):

Declare
    l_Children_List                json_list;
    JSON_Obj                     json;
    l_Child_JSON_Obj                     json;
Begin
IF (JSON_Obj.exist ('children')) THEN
    IF (JSON_Obj.get ('children').is_array)
    l_Children_List := json_list (JSON_Obj.get ('children'));
    FOR i IN 1 .. l_Children_List.COUNT

        IF (JSON_Obj.exist ('children')) THEN
            IF (JSON_Obj.get ('children').is_array)
            l_Children_List := json_list (JSON_Obj.get ('children'));
            FOR i IN 1 .. l_Children_List.COUNT

                jSON_child_val := l_Children_List.get (i);
                l_Child_JSON_Obj := json (jSON_child_val );

            LOOP
        End If;

    LOOP
End If;
End;

0 个答案:

没有答案