0 Replies Latest reply on Nov 28, 2016 3:23 AM by 3351610

    apex_json work-around for bug

    3351610

      apex_json has some buggy behavior illustrated below.

       

      procedure "JSON_TEST"(idin in varchar2) AS

          c1 sys_refcursor;

          c2 sys_refcursor;

        BEGIN

          open c1 for

             select idin as "test" from dual;

          open c2 for

             select idin as "test", cursor ( select 'a' as "b" from dual ) "cur" from dual;

          

          APEX_JSON.initialize_clob_output;

       

          apex_json.open_object;

          apex_json. write('t1', c1 );

          apex_json. write('t2', c2 );

          apex_json.close_object;

       

          DBMS_OUTPUT.put_line(APEX_JSON.get_clob_output);

          APEX_JSON.free_output;

      END "JSON_TEST";

       

      begin

      JSON_TEST('1');

      end;

       

      This results in

      {

      "t1":[

      {

      "test":"1"

      }

      ]

      ,"t2":[{"test":1,"cur":[{"b":"a"}]}]

      }

       

      Now in t1 the test is a string as expected but its a number in t2 although the only difference is adding a cursor.

      Does anyone else see this how do I work around it?