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

Close

JSON

Help
CR
2010-11-10
2012-10-08
  • CR
    CR
    2010-11-10

    Can you convert a JSON object to XML using Saxon Java Parser (Saxon HE 9.2)?
    Thanks

     
  • Michael Kay
    Michael Kay
    2010-11-11

    No, sorry, there's no current support in Saxon for parsing JSON. It's
    something I would like to add. One possibility is to parse it into the format
    defined by John Snelson at http://snelson.org.uk/archives/2008/02/parsing_jso
    n_in.php.

    Another possibility is to parse it into a combination of maps, sequences, and
    atomic values (using the new Map extension in Saxon 9.3). If you have input on
    the requirements, and use cases, please share them!

     
  • David Lee
    David Lee
    2010-11-11

    I'm currently working on a long term project to support lossless JSON-XML
    mapping. Its got a way to go.
    But some of the early phases will be released shortly (by next week) in the
    next version of xmlsh (www.xmlsh.org)
    This includes a parser and serializer of JSON to/from a specific JSON XML
    format which can accomidate any JSON data losslessly. However I consider it an
    'intermediate format' because the XML is very JSON specific. Its simple
    though, so can be parsed with Saxon (xslt/xquery/xpath) very trivially, and in
    fact uses saxon internally.
    An simple example

    JSON:
    { "foo" : "bar" , "array" : }

    XML (lets hope the tags survive the post)

    <OBJECT>
    <MEMBER name="foo">
    <STRING>bar</STRING>
    </MEMBER>
    <MEMBER name="array">
    <ARRAY>
    <NUMBER>1</NUMBER>
    <NUMBER>2</NUMBER>
    <STRING>three</STRING>
    </ARRAY>
    </MEMBER>
    </OBJECT>

    I will post back here when this is released (soon!). Look for the "json2xml"
    and "xml2json" commands.

    -David Lee
    dlee@calldei.com
    www.xmlsh.org