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] List of differences between XML and JSON?

On 5/3/2015 1:45 AM, Dimitre Novatchev wrote:
Now, notice that the book object representing "The Giver" by Lois Lowry,
takes part in both collections. This is another example how two
different JSON objects share a single third JSON object.

One could argue that these are two different JSON objects that happen to
represent the same book. This is not true, because these "two objects"
cannot have their own different data and if we want to change, for
example, the year when the book was written, we must make the change in
both of these "two objects".
Well, actually, there is nothing to indicate that these two objects are the same. A javascript engine would create two objects, and if you were to change the properties of one, the other's properties would not automatically change.

A graph is a set of nodes and edges. Each edge is labeled with the two nodes that is connects (well, there could be a separate record of these connections, but this is one way). So a simple JSON graph could be given by (omitting quotations marks from the labels "edge" and "node" for simplicity):

{node: "N1"}, {node: "N2"}, {node: "N3"},
{edge: {from: "N1", to: "N2"}},
{edge: {from: "N2", to: "N3"}},
{edge: {from: "N1", to: "N3"}}

You could also use edge:["N1", "N2"], ..., but the first way lets you add other named properties to an edge.

You could augment the properties of each node or edge as you like, of course. It's true that nothing in the JSON shows (by the construction of the objects) that the nodes have any relation to the edges. Your code has to provide that interpretation. That's because JSON does not provide a notion of object identity, just objects and lists. But this lack comes from the simplicity.

[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