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] An argument for dropping (deleting) namespaceprefixes when converting XML to JSON

On Mon, 2015-05-18 at 15:48 +0000, Costello, Roger L. wrote:
> Hi Folks,
> 
> Consider the bk: namespace prefix in this XML snippet:
> 
>     <bk:Title>The Adventures of Huckleberry Finn</bk:Title>
> 
> How would you convert that XML to JSON? Would you create this JSON:
> 
>    "bk:Title": "The Adventures of Huckleberry Finn"

I'd probably convert it to something like:

    {
       "Title" : "The Adventures of Huckleberry Finn",
       "xmlns" : "http://www.example.org/titles/";
    }

Othewise what do you do if you have a Title element from two different 
namespaces intermixed in the same document?

But for additional smarts there's no need to repeat the "xmlns" 
binding on contained objects if there's no ambiguity.

Liam


> I will argue against doing that. The bk: prefix has meaning to XML 
> parsers and XML applications, but it has no meaning to JSON parsers 
> or JSON applications. In fact, the whole notion of namespaces is 
> foreign to JSON.
> 
> Emulating XML with JSON is a bad idea.
> 
> When converting XML to JSON I recommend dropping (deleting) all 
> namespace prefixes. Further, drop/delete all namespace declarations. 
> Thus, convert the above XML to this JSON:
> 
>    "Title": "The Adventures of Huckleberry Finn"
> 
> If it is necessary to indicate that the Title is a book title, then 
> create this JSON:
> 
>     "Book Title": "The Adventures of Huckleberry Finn"
> 
> I invite your thoughts on this issue.
> 
> /Roger


[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