APEX_JSONを使用してPL/SQLでJSONを解析しようとしています
私のJSON応答は次のようなものです..
[
{
"NAME": "SAMPLE123",
"SECOND_NAME": "MIDWEST MEDIA GROUP, INC",
"ADDRESS": null,
"PHONE_NUM": "050149603"
},
{
"PHONE_NUM": "010609568",
"ADDRESS": "BETTER VENDORS ASSOCIATION",
"SECOND_NAME": "B V A CO OP INC",
"NAME": "SAMPLE123"
},
{
"PHONE_NUM": "111942970",
"ADDRESS": null,
"NAME": "SAMPLE123",
"SECOND_NAME": "BALDWIN'S BUSINESS SYSTEMS, INC."
},
{
"SECOND_NAME": "INNOVATIVE SALES TECHNOLO",
"NAME": "SAMPLE123",
"ADDRESS": null,
"PHONE_NUM": "626904713"
},
{
"ADDRESS": null,
"PHONE_NUM": "050717132",
"SECOND_NAME": "JEFFREY A. AVNY ATTORNEY AT LAW",
"NAME": "SAMPLE123"
},
{
"PHONE_NUM": "079203229",
"ADDRESS": null,
"SECOND_NAME": "3CLOUDS INC",
"NAME": "SAMPLE123"
},
{
"SECOND_NAME": "ARTHUR N SKLADMAN MD SC",
"NAME": "SAMPLE123",
"PHONE_NUM": "792034886",
"ADDRESS": "SKLADMAN, ARTHUR"
}]
PL/SQLで次のコードを書きました
sJsonIndex APEX_JSON.t_values;
APEX_JSON.parse(sJsonIndex, clob_buff);
DBMS_OUTPUT.PUT_LINE(clob_buff);
sCount := APEX_JSON.get_count(p_path => '.' , p_values => sJsonIndex);
DBMS_OUTPUT.PUT_LINE('sCount ' || sCount);
IF sCount > 0 THEN
FOR i in 1 .. sCount LOOP
A_id := APEX_JSON.get_varchar2(
p_values => sJsonIndex,
p_path => 'NAME['|| i ||']');
--A_id := APEX_JSON.get_varchar2('NAME['|| i ||']');
DBMS_OUTPUT.PUT_LINE('sCount i ' || i);
DBMS_OUTPUT.PUT_LINE('A_id i ' || A_id);
END LOOP;
END IF;
以下の出力が得られます。
sCount i 1
A_id i
sCount i 2
A_id i
sCount i 3
A_id i
sCount i 4
A_id i
sCount i 5
A_id i
sCount i 6
A_id i
sCount i 7
A_id i
sCount i 8
A_id i
sCount i 9
A_id i
sCount i 10
A_id i
誰でも助けてもらえますか?..私はAPEX_JSONが初めてです