Menu

Parsing naked JSON arrays

Anonymous
2013-02-06
2013-05-28
  • Anonymous

    Anonymous - 2013-02-06

    Hi folks,

    I was wondering if anyone previously has added a request for accepting JSON arrays at the root level, e.g.

    select json('') from dual;

    This is valid JSON but returns "ORA-20101: JSON Parser exception - no { start found" which seems to imply the parser only accepts outer braces on any incoming document.

    Note my usage case is accepting JSON responses from Neo4j.

    Thanks,
    Paul

     
  • James Sumners

    James Sumners - 2013-02-06

    Try this instead:

    select json_list('[{"bub":1},{"foo":2}]') from dual;
    

    It looks like what you were doing was using json_parser.parser to convert the string. This function does expect the input string to represent a top level object and not an array. I think the easiest solution is to look at the first character of the incoming string to decide which parser to use - json() or json_list().

     

Log in to post a comment.