Search code examples
oraclepljson

How to parse this JSON where name has ','


I run next example

declare
    obj json := json('{"TR,A" : "OK" }');
begin
    dbms_output.put_line(JSON_EXT.GET_STRING (obj, 'TR,A'));
end;

and receive a message

ORA-20110: JSON Path parse error: expected . or [ found , at position 4
ORA-06512: at "SCOTT.JSON_EXT", line 193
ORA-06512: at "SCOTT.JSON_EXT", line 201

What is the work around?


Solution

  • The following code works for me:

    declare
      my_json json := json('{"TR,A" : "OK" }');
    begin
      dbms_output.put_line(my_json.get('TR,A').to_char);
    end;
    

    You should work directly with the JSON type. You should only have to resort to using packages like JSON_EXT if the type methods are insufficient for your use case.