Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get an json array in pl/sql

Klaus SørensenFeb 9 2021 — edited Feb 9 2021

Hi
When I run the script below, I get this error.
[Error] Execution (1: 1): ORA-30625: method dispatch on NULL SELF argument is disallowed
ORA-06512: at line 25
I obviously do not get the array in line 24.
Any suggestions ?
Thanks Klaus
DECLARE
l_json_input VARCHAR2(32000) := '{
"match":{
"emails": [
{
"usage": "/alka/forsikring/marketing",
"email": "spam@klump.835a5dd3-46db-4b69-827e-1529f72cb3a9.dk"
},
{
"usage": "/alka/forsikring/forretning",
"email": "rasmus@klump.835a5dd3-46db-4b69-827e-1529f72cb3a9.dk"
}
]
}
}
';
l_result JSON_ELEMENT_T;
l_document_object JSON_OBJECT_T;
l_array JSON_ARRAY_T; --contact array
BEGIN
l_result := JSON_ELEMENT_T.parse(l_json_input);
l_document_object := TREAT(l_result AS JSON_OBJECT_T);
IF JSON_EXISTS(l_json_input,'$.match.emails') THEN
l_result := l_document_object.get('match.emails');
IF (l_result.IS_ARRAY()) THEN
l_array := treat ( l_result AS JSON_ARRAY_T);
dbms_output.put_line(l_array.GET_SIZE());
END IF;
END IF;
END;

Comments
Post Details
Added on Feb 9 2021
2 comments
187 views