Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

No json

2009-12-02
2013-05-28
  • I try to use PLJSON and durign my test I get a problem with the print and to_char functions.

    My Script for Example:

        set serveroutput on format wrapped;
        declare
          big_str varchar2(1024);
          objpr json := json('{"a": [1,[{"a":{"i":}},15] ] }');
          -
          procedure p(v varchar2) as begin dbms_output.put_line(null);dbms_output.put_line(v); end;
        begin
          big_str := objpr.to_char;
          p('Result(2): ' || big_str);
        end;
        /

    -  ---------------
    And the result:

              }]"A" : 2
        } }, 15]]

    … it's a little bit different to the initial Json-String.

    I get the same problems with som Example-Script, but some testscripts works fine. So I think there is a problem in the print/to_char-function

    I use the actual PLJSON with "Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production" with SQLPlus.

     
  • It work correct when I set the boolean operator for blanks to "false".

        set serveroutput on format wrapped;
        declare
          big_str varchar2(1024);
          objpr json := json('{"a": [1,[{"a":{"i":}},15] ] }');
          -
          procedure p(v varchar2) as begin dbms_output.put_line(null);dbms_output.put_line(v); end;
        begin
          big_str := objpr.to_char(false);
          p('Result(2): ' || big_str);
        end;
        /

    And I get following result:

        Result(2): {"a":[1,[{"a":{"i":}},15]]}

    This is ok.

     
  • Hmmm - sure looks strange.

    Are you sure that PLJSON was installed correctly?
    Another user encountered a problem with simpletypes.typ on 11g. Try to uninstall, and reinstall with a change in simpletypes.typ: https://sourceforge.net/projects/pljson/forums/forum/935365/topic/3475598?message=7794287.

    The problem could also be a linebreak issue (CR LF). Look in the prettyprinter package to fix that. Try chr(13)||chr(10) or chr(10) or chr(13).

    After the installation you should try to run the testscript to see if everything is working alright.

    Let me know your results.

     
  • The installaion runs without errors after i fixed the uninstall.sql. I get the problem later.

    Maybee the reason ist, that I use the old tool sqlplus. Sqlplus does not work with a modern display output.

    I make some tests and get success when I make following changes in JSON_PRINTER:

    Old:

          function newline(spaces boolean) return varchar2 as
          begin
            if(spaces) then return chr(13); else return ''; end if;
          end;

    New:

          function newline(spaces boolean) return varchar2 as
          begin
            if(spaces) then return chr(13)||chr(10); else return ''; end if;
          end;

    And the result from my testscript looks much better:

        Result(2): {
          "a" : [1, [{
            "a" : {
              "i" : [{
                "A" : 2
       
          }]
            }
          }, 15]]
        }

    It's great! Thank you!!!!

     
  • Thank you for your error report. I will add an linebreak option in the Pretty printer in the next release

     
  • I confirmed that commenting out the "uninstall.sql" line in the install script prevented the errors I was receiving on install through SqlPlus.