How can I retrieve content from below JSON using Pl/JSON? i need to fetch values of first array and second array
{
"documents1": [
{
"key": "NATID",
"validations": [
{
"error": "Field is required"
}
]
}
]
}
for example i have written the query as below which returns values of first array without any issue, but it doesn't return values of array of an array
DECLARE
obj json
:= json
('{
"documents1": [
{
"key": "NATID",
"validations": [
{
"error": "Field is required"
}
]
}
]
}'
);
list_value json_list;
list_value_validation json_list;
LIST_VALUES json_list;
BEGIN
list_value := json_list (obj.get ('documents'));
FOR i IN 1 .. list_value.COUNT
LOOP
DBMS_OUTPUT.put_line ( 'key->'
|| json_ext.get_string (json (list_value.get (i)),
'key'
)
);
----------below scripts are not working
list_value_validation := json_list (list_value.get ('values'));
FOR iv IN 1 .. list_value_validation.COUNT
LOOP
DBMS_OUTPUT.put_line
( 'error->'
|| json_ext.get_string
(json (list_value_validation.get (iv)
),
'error'
)
);
END LOOP;
END LOOP;
END;