Forum Stats

  • 3,768,285 Users
  • 2,252,771 Discussions
  • 7,874,515 Comments

Discussions

Valid JSON_ARRAY_T

User_CI7SY
User_CI7SY Member Posts: 61 Green Ribbon

Could you please help me understand why 1) is not valid JSON_ARRAY_T and 2) is?

1)ARR := JSON_ARRAY_T('[{"Address1":"3121,"Address2":"Suite 301"},{"Address1":"3121","Address2":"Suite 301"}]');

  2)ARR := JSON_ARRAY_T('[{"Address1":"3121"},{"Address1":"3121"}]');


I run below code and it fails.

DECLARE 

ARR JSON_ARRAY_T ;

BEGIN

  ARR := JSON_ARRAY_T('[{"Address1":"3121,"Address2":"Suite 301"},{"Address1":"3121","Address2":"Suite 301"}]');

  DBMS_OUTPUT.PUT_LINE('BASIC: ' || ARR.TO_STRING);

 FOR indx IN 0 .. ARR.get_size - 1

  LOOP

   DBMS_OUTPUT.put_line(ARR.get_string(indx));

  END LOOP;

END;


Error:

Error report -

ORA-40441: JSON syntax error

ORA-06512: at "SYS.JDOM_T", line 4

ORA-06512: at "SYS.JSON_ARRAY_T", line 29

ORA-06512: at line 6

40441. 00000 - "JSON syntax error"

*Cause:  The provided JavaScript Object Notation (JSON) data had invalid

      syntax and could not be parsed.

*Action:  Provide JSON data with the correct syntax.

Answers