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

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

Expand Messages
  • Mark Joseph
    Sep 16, 2009
    • 0 Attachment
      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