Menu

BUG: is_string returns TRUE for bool and null vaues

2014-10-01
2014-11-30
  • Malnormalulo

    Malnormalulo - 2014-10-01
    DECLARE
      str VARCHAR2(100);
      foo json_list;
    BEGIN
      str :=
        --  1     2    3    4    5   6
        '[ TRUE, NULL, 1, "bar", {}, [] ]';
      foo := json_list(str);
    
      DBMS_OUTPUT.PUT_LINE('i is_string');
      DBMS_OUTPUT.PUT_LINE('-----------');
      FOR i IN 1..foo.COUNT LOOP
        DBMS_OUTPUT.PUT_LINE(
          TO_CHAR(i)||' '|| CASE WHEN foo.get(i).is_string() THEN 'TRUE' ELSE 'FALSE' END
        );
      END LOOP;
    END;
    /
    

    Expected output:

    i is_string
    -----------
    1 FALSE
    2 FALSE
    3 FALSE
    4 TRUE
    5 FALSE
    6 FALSE



    Actual output:

    i is_string
    -----------
    1 TRUE
    2 TRUE
    3 FALSE
    4 TRUE
    5 FALSE
    6 FALSE

     
  • James Sumners

    James Sumners - 2014-10-01

    Please a file a bug at https://github.com/jsumners/pljson

    I'll look at it when I can, but if you submit a pull request with a fix it'd probably get fixed faster.

     
  • Malnormalulo

    Malnormalulo - 2014-10-07

    I'll file the bug. I'd debug and write the fix myself, but legal circumstances prevent me - sorry!

     
  • Jonas Krogsboell

    There is no error. The non-strict parsing creates two strings: "TRUE" and "NULL". If you used parser in strict mode, the JSON would have failed.

     

Log in to post a comment.