XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] XML vs JSON

I think one can probably prove that no mapping JSON to/from XML will satisfy all the following objectives:

(1) Handles any JSON document
(2) Handles any XML document
(3) is round-trippable (to-json(to-xml(J)) = J, and to-xml(to-json(X)) = X).

and the more you try and get close to this, the more you sacrifice two further objectives

(4) produces a user-friendly XML representation of JSON
(5) produces a user-friendly JSON representation of XML

In the XSLT 3.0 mapping we focused on achieving (1) and (3) and doing the best we could on (4) within these constraints. One reason we chose these objectives is that the user is operating in a world where they have good tools for transforming any XML that comes out of the conversion to a form that they prefer.

If you choose a different set of objectives you will end up with a different mapping.

Michael Kay
Saxonica


On 5 Oct 2017, at 10:07, Peintner, Daniel <daniel.peintner.ext@siemens.com> wrote:

Hi,

Many of these JSON<->XML tools provide a good coverage for some XML/JSON constructs but not for all.

The tool [1] you pointed to fails for example when converting the following "simple" JSON example to XML.

{ "a number": 1 }

The reason is rather simple. The qualified name in XML has some restrictions that are more rigid than the JSON fieldnames.

Hence, we in the EXI working group worked on a more sophisticated approach when converting JSON to XML infoset [2]. This requires escaping as shown here [3] for the example above.

Note1: The Efficient XML Interchange (EXI) format would not have the same restrictions as XML but the working group concluded that any EXI document should be convertible to XML.

Note2: The XSLT working group uses yet another scheme [4] which for EXI did not work given that we want to allow for user-defined XML schemas.

Having said that, there seem to be many approaches and solutions,

-- Daniel

[1] www.utilities-online.info/xmltojson/
[2] https://www.w3.org/XML/EXI/docs/json/exi-for-json.html
[3] https://www.w3.org/XML/EXI/docs/json/exi-for-json.html#exampleKeynameEscaping
[4] https://www.w3.org/TR/xslt-30/schema-for-json.xsd

 
 

Von: Mukul Gandhi [gandhi.mukul@gmail.com]
Gesendet: Freitag, 22. September 2017 08:08
An: xml-dev@lists.xml.org
Betreff: [xml-dev] Re: XML vs JSON

With respect to this thread, I could see that people have written tools to convert between XML and JSON (both ways). This seems to be nice: www.utilities-online.info/xmltojson/

On 1 August 2017 at 17:04, Mukul Gandhi <gandhi.mukul@gmail.com> wrote:
Hello,
    I don't intend to spark a bitter debate between XML & JSON, where the outcome of debate is win of one over other. Rather, I wish to present in a friendly manner, according to me, where these two technologies differ.

When talking about designing REST services, JSON seems to clearly win. The whole software world seems to be biased in favour of JSON it seems, for this criteria. Although I have read, that in many cases REST services can use XML instead of JSON. I think, JSON's major use case is in the use within REST.

Having worked quite a bit with Android mobile apps, that framework by default relies heavily on XML. I haven't seen JSON being used by default in that area. Although, JSON is many times used in feeding and fetching JSON data from various kinds of services (remote REST services, local API calls etc), in Android apps.

XML when considering other technologies in combination, like XML Schema and XML databases, have a scale close to RDBMSs. JSON is no where near this.

Any other thoughts from the experts here?




--
Regards,
Mukul Gandhi



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS