Loading ...
Sorry, an error occurred while loading the content.

1392Re: SV: [json] JSON representation for XML snippet

Expand Messages
  • stephen.mckamey
    Sep 17, 2009
      The encoding used by JsonML <http://jsonml.org> isn't prioritized to be "pretty" or even really encoded by humans. It is intended to be compact and loss-less. This means it can unambiguously encode and decode valid XML. Namespaces are handled the same way as XML 1.0: as part of the element (or attribute) name.

      Off-topic: Where JsonML really fills a void is its ability to be extended to be a full intermediate language for client-side templates. Templates are written by humans in an ASP/JSP style syntax and then compiled to JsonML+Browser-Side Templates (JBST) <http://bit.ly/2poc6d>. No parsing has to take place in the browser, and the site markup may be fully compacted and cached with the rest of the scripts as it is now pure JavaScript.

      --- In json@yahoogroups.com, "Mark Joseph" <mark@...> wrote:
      > Handling XML attributes when converting to JSON:
      > **************************************
      > <attribute a2="v2">value2</attribute>
      > will be
      > {"attribute":{"a2":"v2"},"#text":"value2"}
      > as example ... while JSONML uses this kind of schema
      > ["nodeName",{"a2":"v2"},"text or nested nodes"]
      > so that this:
      > <attributes>
      > <attribute a2="v2">value2</attribute>
      > </attributes>
      > will be this
      > ["attributes",{},["attribute",{"a2":"v2"},"value2"]]
      > ****************************************
      > So all of the above works well when you have simple XML.
      > But with something like:
      > <node1 a="45">
      > <node2 b="9" c="hithere">
      > <node3 d="abc">
      > <node4 e="12345">JSON has no attributes</node4>
      > </node3>
      > </node2>
      > Now is the time for all good men to come to the aid of their party
      > <node5 d="45">temperature is 70 degrees today</node5>
      > </node1>
      > The resulting JSON is going to be "ugly". Many added arrays
      > are added to handle the attributes and nested nodes now appear in the
      > added arrays. To me this adds a lot of extra complexity that I am
      > not sure I want.
      > Best,
      > Mark Joseph, Ph.D.
      > P6R, Inc
    • Show all 28 messages in this topic