Issue with JSON output

Anonymous
2013-04-19
2013-05-28
  • Anonymous - 2013-04-19

    Hi,
    I've just installed the library and am having an issue with the output.
    Given this simple XML string:

    <permit_list>
        <permit>
            <a>123</a>
            <b>123</b>
        </permit>
        <permit>
            <a>asdf</a>
            <b>asdfgasdgadsfh</b>
        </permit>
    </permit_list>
    

    and this PL/SQL (direct from the example):

    set serveroutput on;
    declare 
      arr json_list;
    begin
      arr := json_ml.xmlstr2json('<permit_list><permit><a>123</a><b>123</b></permit><permit><a>asdf</a><b>asdfgasdgadsfh</b></permit></permit_list>');
      arr.print;
    end;
    

    I get the following JSON:

    ["permit_list", ["permit", ["a", "123"], ["b", "123"]], ["permit", ["a", "asdf"], ["b", "asdfgasdgadsfh"]]]
    

    Which doesnt represent the original XML structure, it  is instead giving me arrays of data rather than the elements.

    Any ideas?
    thanks.

     
  • James Sumners

    James Sumners - 2013-04-19

    From http://www.jsonml.org/ :

    JsonML (JSON Markup Language) is an application of the JSON (JavaScript Object Notation) format. The purpose of JsonML is to provide a compact format for transporting XML-based markup as JSON which allows it to be losslessly converted back to its original form.

    From the jsonml package:

    This transformation converts any XML document into JsonML.

    So… you got exactly what you asked for. JSONML != JSON.

     
  • Anonymous - 2013-05-02

    Thanks, but is there a way to convert an XML obj to a proper JSON obj? Or only the JSONML representative form?

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks