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

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

Expand Messages
  • Tatu Saloranta
    ... Right, I did skim through it, it s just that article is omitting a few details. The basic idea of exposing JSON as SAX events is of course simple (and
    Message 1 of 28 , Sep 14, 2009
    • 0 Attachment
      On Mon, Sep 14, 2009 at 12:46 PM, Mark Joseph <mark@...> wrote:
      > So the way the system works is that our JSON parser is called from a plugin to our DOM parser.   That plugin calls the DOM parser API that creates nodes in the DOM tree.
      > This is documented in another article:
      > https://www.p6r.com/articles/2008/05/06/xslt-and-xpath-for-json/
      >
      > The plugin architecture is also used for XML, where a separate plugin calls our SAX-2 XML parser so they both work the same way.

      Right, I did skim through it, it's just that article is omitting a few
      details. The basic idea of exposing JSON as SAX events is of course
      simple (and obvious, but useful): JSON start/end object/array gets
      converted to SAX start/end element events, no attributes.

      But one thing I didn't see mentioned was the the question of mapping
      JSON arrays (it does mention use of "JSON-document” as dummy name for
      outermost JSON object, which is needed). In XML there are couple of
      ways of expressing logical arrays (sequences of items), so one has to
      choose one from alternatives (separate container for array itself? or
      for elements? or both? and what name to use for either?)
      So it seems that either JSON arrays are not supported, or that details
      are just not mentioned.
      Also: this problem affects JSON output as well.

      Another smaller issue is handling of JSON content with characters that
      are legal in JSON, but illegal in XML (like control characters) is not
      mentioned. Maybe such content is just passed as is; which works ok
      unless app code is assuming that no such content will be received.

      -+ Tatu +-
    • Andrea Giammarchi
      I do not get all these problems ... first of all I expect that JSON to XML will parse JSON first and then create XML via proper namespace/libarry and character
      Message 2 of 28 , Sep 14, 2009
      • 0 Attachment
        I do not get all these problems ... first of all I expect that JSON to XML
        will parse JSON first and then create XML via proper namespace/libarry and
        character problem should not exist in this case.

        Secondly ASAIK JSON escapes a lot of characters adding \uXXXX from 0000 to
        FFFF, other characters are escaped like \\n and the rest is basically ASCII.
        Which parser gives you all these problems during convertion, assuming you
        are avoiding the "to Current Language before, to XML after" strategy?

        On Mon, Sep 14, 2009 at 9:04 PM, Tatu Saloranta <tsaloranta@...>wrote:

        > On Mon, Sep 14, 2009 at 12:46 PM, Mark Joseph <mark@...> wrote:
        > > So the way the system works is that our JSON parser is called from a
        > plugin to our DOM parser. That plugin calls the DOM parser API that
        > creates nodes in the DOM tree.
        > > This is documented in another article:
        > > https://www.p6r.com/articles/2008/05/06/xslt-and-xpath-for-json/
        > >
        > > The plugin architecture is also used for XML, where a separate plugin
        > calls our SAX-2 XML parser so they both work the same way.
        >
        > Right, I did skim through it, it's just that article is omitting a few
        > details. The basic idea of exposing JSON as SAX events is of course
        > simple (and obvious, but useful): JSON start/end object/array gets
        > converted to SAX start/end element events, no attributes.
        >
        > But one thing I didn't see mentioned was the the question of mapping
        > JSON arrays (it does mention use of "JSON-document� as dummy name for
        > outermost JSON object, which is needed). In XML there are couple of
        > ways of expressing logical arrays (sequences of items), so one has to
        > choose one from alternatives (separate container for array itself? or
        > for elements? or both? and what name to use for either?)
        > So it seems that either JSON arrays are not supported, or that details
        > are just not mentioned.
        > Also: this problem affects JSON output as well.
        >
        > Another smaller issue is handling of JSON content with characters that
        > are legal in JSON, but illegal in XML (like control characters) is not
        > mentioned. Maybe such content is just passed as is; which works ok
        > unless app code is assuming that no such content will be received.
        >
        > -+ Tatu +-
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >
        >


        [Non-text portions of this message have been removed]
      • Mark Joseph
        But one thing I didn t see mentioned was the the question of mapping JSON arrays (it does mention use of JSON-document” as dummy name for outermost JSON
        Message 3 of 28 , Sep 14, 2009
        • 0 Attachment
          But one thing I didn't see mentioned was the the question of mapping
          JSON arrays (it does mention use of "JSON-document” as dummy name for
          outermost JSON object, which is needed). In XML there are couple of
          ways of expressing logical arrays (sequences of items), so one has to
          choose one from alternatives (separate container for array itself? or
          for elements? or both? and what name to use for either?)
          So it seems that either JSON arrays are not supported, or that details
          are just not mentioned.
          Also: this problem affects JSON output as well.
          The the code that generates JSON output detects an array in the DOM tree and
          generates a JSON array from it. The "array" are just several nodes in the tree
          with the same element name that are adjacent to each other.

          The JSON parsing to DOM nodes just places all the array elements adjacent to each
          other in the tree with the same name. But this is an internal implementation thing that I could
          do several ways. (I could add a special node in the DOM tree indicating an array
          start and array end. Where these nodes are not output.)

          What is in the DOM tree is not XML and not JSON and not any other format. It
          is instead an intermediate format with extra "schematic" marker nodes a necessary
          to indicate other information.


          Another smaller issue is handling of JSON content with characters that
          are legal in JSON, but illegal in XML (like control characters) is not
          mentioned. Maybe such content is just passed as is; which works ok
          unless app code is assuming that no such content will be received.
          Well I can't discuss everything in a single article, but in the DOM tree there are
          no illegal characaters since at that point its not XML. However, when you take
          the DOM tree and want to output it as XML then there are standard escape/encoding
          rules in XML that are used to force proper XML.

          What is really nice about our approach is now I can add another plugin that takes our
          ASN.1 parser (for example) and converts that into a DOM tree (since it has structure too). And then
          do whatever I want to it.



          Best,
          Mark
          P6R, Inc




          -+ Tatu +-


          ------------------------------------

          Yahoo! Groups Links





          [Non-text portions of this message have been removed]
        • Mark Joseph
          ... *************************************** My Response: The the code that generates JSON output detects an array in the DOM tree and generates a JSON array
          Message 4 of 28 , Sep 14, 2009
          • 0 Attachment
            Sorry the previous version of this message was hard to read:


            >But one thing I didn't see mentioned was the the question of mapping
            >JSON arrays (it does mention use of "JSON-document” as dummy name for
            >outermost JSON object, which is needed). In XML there are couple of
            >ways of expressing logical arrays (sequences of items), so one has to
            >choose one from alternatives (separate container for array itself? or
            >for elements? or both? and what name to use for either?)
            >So it seems that either JSON arrays are not supported, or that details
            >are just not mentioned.
            >Also: this problem affects JSON output as well.


            ***************************************
            My Response:

            The the code that generates JSON output detects an array in the DOM tree and
            generates a JSON array from it. The "array" are just several nodes in the tree
            with the same element name that are adjacent to each other.

            The JSON parsing to DOM nodes just places all the array elements adjacent to each
            other in the tree with the same name. But this is an internal implementation thing that I could
            do several ways. (I could add a special node in the DOM tree indicating an array
            start and array end. Where these nodes are not output.)

            What is in the DOM tree is not XML and not JSON and not any other format. It
            is instead an intermediate format with extra "schematic" marker nodes a necessary
            to indicate other information.

            ***************************************


            >Another smaller issue is handling of JSON content with characters that
            >are legal in JSON, but illegal in XML (like control characters) is not
            >mentioned. Maybe such content is just passed as is; which works ok
            >unless app code is assuming that no such content will be received.


            *****************************************
            My Response:

            Well I can't discuss everything in a single article, but in the DOM tree there are
            no illegal characaters since at that point its not XML. However, when you take
            the DOM tree and want to output it as XML then there are standard escape/encoding
            rules in XML that are used to force proper XML.

            What is really nice about our approach is now I can add another plugin that takes our
            ASN.1 parser (for example) and converts that into a DOM tree (since it has structure too). And then
            do whatever I want to it.

            Best,
            Mark
            P6R, Inc

            ****************************************
          • Shalab Goel
            Thank you for all the responses. I guess there were two parts to it. I was specifically interested in your insights on a XML element with both text and
            Message 5 of 28 , Sep 14, 2009
            • 0 Attachment
              Thank you for all the responses. I guess there were two parts to it. I was
              specifically interested in your insights on a XML element with both text and
              attributes
              can be represented in JSON.

              <attribute a2="v2">value2</attribute>

              If XML were

              <attribute a2="v2">value2</attribute>

              equivalent JSON could be

              {"attribute" : "value2"}

              if XML were

              <attribute a2="v2" />

              JSON could be

              {
              "attribute" :
              { "a2" : "v2" }
              }

              But how about when both XML element's text and attributes are specified
              as in

              <attribute a2="v2">value2</attribute>

              Thanks
              Shalab

              On Mon, Sep 14, 2009 at 1:36 PM, Mark Joseph <mark@...> wrote:

              >
              >
              > But one thing I didn't see mentioned was the the question of mapping
              > JSON arrays (it does mention use of "JSON-document� as dummy name for
              > outermost JSON object, which is needed). In XML there are couple of
              > ways of expressing logical arrays (sequences of items), so one has to
              > choose one from alternatives (separate container for array itself? or
              > for elements? or both? and what name to use for either?)
              > So it seems that either JSON arrays are not supported, or that details
              > are just not mentioned.
              > Also: this problem affects JSON output as well.
              > The the code that generates JSON output detects an array in the DOM tree
              > and
              > generates a JSON array from it. The "array" are just several nodes in the
              > tree
              > with the same element name that are adjacent to each other.
              >
              > The JSON parsing to DOM nodes just places all the array elements adjacent
              > to each
              > other in the tree with the same name. But this is an internal
              > implementation thing that I could
              > do several ways. (I could add a special node in the DOM tree indicating an
              > array
              > start and array end. Where these nodes are not output.)
              >
              > What is in the DOM tree is not XML and not JSON and not any other format.
              > It
              > is instead an intermediate format with extra "schematic" marker nodes a
              > necessary
              > to indicate other information.
              >
              > Another smaller issue is handling of JSON content with characters that
              > are legal in JSON, but illegal in XML (like control characters) is not
              > mentioned. Maybe such content is just passed as is; which works ok
              > unless app code is assuming that no such content will be received.
              > Well I can't discuss everything in a single article, but in the DOM tree
              > there are
              > no illegal characaters since at that point its not XML. However, when you
              > take
              > the DOM tree and want to output it as XML then there are standard
              > escape/encoding
              > rules in XML that are used to force proper XML.
              >
              > What is really nice about our approach is now I can add another plugin that
              > takes our
              > ASN.1 parser (for example) and converts that into a DOM tree (since it has
              > structure too). And then
              > do whatever I want to it.
              >
              > Best,
              > Mark
              > P6R, Inc
              >
              > -+ Tatu +-
              >
              >
              > ------------------------------------
              >
              > Yahoo! Groups Links
              >
              >
              >
              >
              >
              > [Non-text portions of this message have been removed]
              >
              >
              >


              [Non-text portions of this message have been removed]
            • Andrea Giammarchi
              just use a non valid attribute name as JSON property, so you won t have ambiguity in the parser. value2 will be
              Message 6 of 28 , Sep 14, 2009
              • 0 Attachment
                just use a non valid attribute name as JSON property, so you won't have
                ambiguity in the parser.

                <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"]]

                Regards

                On Mon, Sep 14, 2009 at 10:23 PM, Shalab Goel <goel.shalab@...> wrote:

                >
                > But how about when both XML element's text and attributes are specified
                > as in
                >
                > <attribute a2="v2">value2</attribute>
                >
                > Thanks
                > Shalab
                >


                [Non-text portions of this message have been removed]
              • Mark Joseph
                ********************************** From: Shalab Goel [mailto:goel.shalab@gmail.com] To: json@yahoogroups.com Sent: Mon, 14 Sep 2009 14:23:34 -0700 Subject: Re:
                Message 7 of 28 , Sep 14, 2009
                • 0 Attachment
                  **********************************
                  From: Shalab Goel [mailto:goel.shalab@...]
                  To: json@yahoogroups.com
                  Sent: Mon, 14 Sep 2009 14:23:34 -0700
                  Subject: Re: SV: [json] JSON representation for XML snippet

                  Thank you for all the responses. I guess there were two parts to it. I was
                  specifically interested in your insights on a XML element with both text and
                  attributes
                  can be represented in JSON.

                  <attribute a2="v2">value2</attribute>

                  If XML were

                  <attribute a2="v2">value2</attribute>

                  equivalent JSON could be

                  {"attribute" : "value2"}

                  if XML were

                  <attribute a2="v2" />

                  JSON could be

                  {
                  "attribute" :
                  { "a2" : "v2" }
                  }

                  But how about when both XML element's text and attributes are specified
                  as in

                  <attribute a2="v2">value2</attribute>
                  *************************************


                  It would be great if there was a standard defined for the transformation, but
                  other than that I can only mention what I have done.

                  I have played with both formats:

                  a flat format:
                  { "attribute" : "value2",
                  "a2" : "v2"
                  }

                  OR

                  An array format:
                  { "attribute" : [ { "a2" : "v2" }, { "value2" } ] }


                  Of course, with either of these outputs we lose something and cannot easily turn this
                  back into XML afterwards. Since JSON has no attributes I have no solution unless
                  everyone agrees to what the mapping should be.


                  Best,

                  Mark Joseph, Ph.D.
                  President
                  P6R, Inc
                  408-205-0361
                  mark@...
                  Skype: markjoseph_sc
                • Tatu Saloranta
                  ... Ok. So DOM tree does have extra metadata that indicates this array-ness . I assumed that DOM tree itself had no knowledge of this, given that SAX API
                  Message 8 of 28 , Sep 14, 2009
                  • 0 Attachment
                    On Mon, Sep 14, 2009 at 1:53 PM, Mark Joseph <mark@...> wrote:
                    > Sorry the previous version of this message was hard to read:

                    >>But one thing I didn't see mentioned was the the question of mapping
                    >>JSON arrays (it does mention use of "JSON-document” as dummy name for
                    ...
                    > ***************************************
                    > My Response:
                    >
                    > The the code that generates JSON output detects an array in the DOM tree and
                    > generates a JSON array from it.   The "array" are just several nodes in the tree
                    > with the same element name that are adjacent to each other.

                    Ok. So DOM tree does have extra metadata that indicates this "array-ness".

                    I assumed that DOM tree itself had no knowledge of this, given that
                    SAX API would not have a way of indicating such data.
                    But if API is just SAX-like (or extension of SAX with additional
                    callback types, startArray/endArray), this could be handled.

                    > The JSON parsing to DOM nodes just places all the array elements adjacent to each
                    > other in the tree with the same name.   But this is an internal implementation thing that I could
                    > do several ways.   (I could add a special node in the DOM tree indicating an array
                    > start and array end.  Where these nodes are not output.)

                    Right. There are multiple ways of exposing it, that is why I asked.

                    > What is in the DOM tree is not XML and not JSON and not any other format.  It
                    > is instead an intermediate format with extra "schematic" marker nodes a necessary
                    > to indicate other information.

                    Ok.

                    > ***************************************
                    >
                    >>Another smaller issue is handling of JSON content with characters that
                    >>are legal in JSON, but illegal in XML (like control characters) is not
                    >>mentioned. Maybe such content is just passed as is; which works ok
                    >>unless app code is assuming that no such content will be received.
                    >
                    > *****************************************
                    > My Response:
                    >
                    > Well I can't discuss everything in a single article, but in the DOM tree there are
                    > no illegal characaters since at that point its not XML.   However, when you take
                    > the DOM tree and want to output it as XML then there are standard escape/encoding
                    > rules in XML that are used to force proper XML.

                    Yes, except that this is not possible in xml 1.0, not even with
                    character entities. There is no way include control characters (except
                    for standard tab, lf, cr) in xml. This is different from having to
                    escape less-than and ampersand characters.
                    XML 1.1 allows for use of character entities for many of these
                    characters, not including null.

                    But I guess this is usually not a significant problem in practice.

                    > What is really nice about our approach is now I can add another plugin that takes our
                    > ASN.1 parser (for example) and converts that into a DOM tree (since it has structure too).   And then
                    > do whatever I want to it.

                    It is good to have interoperability tools, and I think this use case
                    makes sense. It is easier to map JSON to XML if necessary than the
                    other way around.

                    Thank you for your explanation,

                    -+ Tatu +-
                  • Mark Joseph
                    ******************************************************* Ok. So DOM tree does have extra metadata that indicates this array-ness . I assumed that DOM tree
                    Message 9 of 28 , Sep 14, 2009
                    • 0 Attachment
                      *******************************************************
                      Ok. So DOM tree does have extra metadata that indicates this "array-ness".

                      I assumed that DOM tree itself had no knowledge of this, given that
                      SAX API would not have a way of indicating such data.
                      But if API is just SAX-like (or extension of SAX with additional
                      callback types, startArray/endArray), this could be handled.
                      ******************************************************

                      Our JSON parser does this:
                      https://www.p6r.com/articles/2008/05/22/a-sax-like-parser-for-json/

                      Its sax2 like in that its event based.


                      >XML 1.1 allows for use of character entities for many of these
                      >characters, not including null.
                      >
                      Since there is no standard way to handle this my code actually output
                      the text "null" so you can see at least what the value was meant to be.



                      Best,
                      Mark
                      P6R, Inc
                    • Tatu Saloranta
                      On Mon, Sep 14, 2009 at 1:33 PM, Andrea Giammarchi ... Unfortunately, no. I am specifically referring to XML inability to contain control characters like 0xA.
                      Message 10 of 28 , Sep 14, 2009
                      • 0 Attachment
                        On Mon, Sep 14, 2009 at 1:33 PM, Andrea Giammarchi
                        <andrea.giammarchi@...> wrote:
                        > I do not get all these problems ... first of all I expect that JSON to XML
                        > will parse JSON first and then create XML via proper namespace/libarry and
                        > character problem should not exist in this case.

                        Unfortunately, no. I am specifically referring to XML inability to
                        contain control characters like 0xA.
                        There is no way to include those in XML 1.0 documents, not even by
                        using character entities (char entity production must match
                        valid-char, which excludes these). They can be included in JSON via
                        escape mechanism.
                        Reverse is not a problem as JSON can contain any Unicode character;
                        any without escaping. I consider this a good thing (at least for
                        String values).

                        -+ Tatu +-
                      • Mark Joseph
                        Handling XML attributes when converting to JSON: ************************************** value2 will be
                        Message 11 of 28 , 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
                        • stephen.mckamey
                          The encoding used by JsonML isn t prioritized to be pretty or even really encoded by humans. It is intended to be compact and loss-less.
                          Message 12 of 28 , Sep 17, 2009
                          • 0 Attachment
                            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
                          • Mark Joseph
                            For people interested in this topic. We are always open to comments and questions. https://www.p6r.com/articles/2010/04/05/xml-to-json-and-back/ Best, Mark
                            Message 13 of 28 , Apr 5, 2010
                            • 0 Attachment
                              For people interested in this topic. We are always open to comments and questions.

                              https://www.p6r.com/articles/2010/04/05/xml-to-json-and-back/


                              Best,

                              Mark Joseph, Ph.D.
                              President
                              P6R, Inc
                              408-205-0361
                              mark@...
                              Skype: markjoseph_sc



                              [Non-text portions of this message have been removed]
                            • Dennis Gearon
                              I m not really interested in this at the moment. BUT, very nice technical work! If I do need it in the future, it s nice to see good quality ideas and
                              Message 14 of 28 , Apr 5, 2010
                              • 0 Attachment
                                I'm not really interested in this at the moment.

                                BUT, very nice technical work! If I do need it in the future, it's nice to see good quality ideas and implentation that I can look for and utilize.

                                Keep up the good work.

                                Dennis Gearon



                                Signature Warning

                                ----------------

                                EARTH has a Right To Life,

                                otherwise we all die.



                                Read 'Hot, Flat, and Crowded'

                                Laugh at http://www.yert.com/film.php

                                --- On Mon, 4/5/10, Mark Joseph <mark@...> wrote:

                                From: Mark Joseph <mark@...>
                                Subject: [json] Where our JSON product is heading: XML to JSON and Back
                                To: json@yahoogroups.com
                                Date: Monday, April 5, 2010, 5:47 PM







                                 









                                For people interested in this topic. We are always open to comments and questions.



                                https://www. p6r.com/articles /2010/04/ 05/xml-to- json-and- back/



                                Best,



                                Mark Joseph, Ph.D.

                                President

                                P6R, Inc

                                408-205-0361

                                mark@...

                                Skype: markjoseph_sc



                                [Non-text portions of this message have been removed]






















                                [Non-text portions of this message have been removed]
                              • stephen.mckamey
                                JsonML ( http://jsonml.org ) handles all of these issues and has been embraced by quite a number of places. Many JSON encoders already include support. It
                                Message 15 of 28 , Apr 6, 2010
                                • 0 Attachment
                                  JsonML ( http://jsonml.org ) handles all of these issues and has been embraced by quite a number of places. Many JSON encoders already include support.

                                  It handles namespaces the same way that XML 1.0 did: include the name as "prefix:local-name" and the URI to prefix mapping (xmlns:abc="http://example.com/abc") as the attribute of the node that declared it.

                                  An early implementation of JsonML took a similar approach to including a child object, but ultimately after some design discussions with Douglas Crockford, his suggestion was to make the actual element an array like the child object and have the element name be the first item.

                                  This positional structure has been the biggest part that people have disliked about JsonML, but yet in many XML documents (XHTML for example, being the primary use case) position of the child nodes is critical to the meaning of the document. So you get much smaller documents when you just add the element name as the first child and make elements arrays.

                                  I'd encourage you to embrace JsonML and contribute to a standard that has been around for four years already rather than creating a slightly different approach.


                                  --- In json@yahoogroups.com, "Mark Joseph" <mark@...> wrote:
                                  >
                                  > For people interested in this topic. We are always open to comments and questions.
                                  >
                                  > https://www.p6r.com/articles/2010/04/05/xml-to-json-and-back/
                                  >
                                  >
                                  > Best,
                                  >
                                  > Mark Joseph, Ph.D.
                                  > President
                                  > P6R, Inc
                                  > 408-205-0361
                                  > mark@...
                                  > Skype: markjoseph_sc
                                  >
                                  >
                                  >
                                  > [Non-text portions of this message have been removed]
                                  >
                                • stephen.mckamey
                                  Not that ugly: [ node1 , { a : 45 }, [ node2 , { b : 9 , c : hithere }, [ node3 , { d : abc }, [ node4 , { e : 12345 }, JSON has no attributes ] ] ], Now is
                                  Message 16 of 28 , Apr 6, 2010
                                  • 0 Attachment
                                    Not that ugly:

                                    ["node1", {"a":"45"},
                                    ["node2", {"b":"9", "c":"hithere"},
                                    ["node3", {"d":"abc"},
                                    ["node4", {"e":"12345"}, "JSON has no attributes"]
                                    ]
                                    ],
                                    "Now is the time for all good men to come to the aid of their party",

                                    ["node5", {"d":"45"}, "temperature is 70 degrees today"]
                                    ]

                                    --- 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
                                    >
                                  • Mark Joseph
                                    Cool stuff, can you show me an example of how JsonML handles XML mixed content, that is not clear to me from the web site. And just so it is clear to me, the
                                    Message 17 of 28 , Apr 6, 2010
                                    • 0 Attachment
                                      Cool stuff, can you show me an example of how JsonML handles XML mixed content, that is not clear to me from the web site.


                                      And just so it is clear to me, the namespace example would be something like:

                                      <description abc="http://example.com"><abc:title>hi there</abc:title></description>

                                      becomes

                                      [ "description", {"abc" : "http://example.com"},
                                      [ "abc:title", {}, "hi there" ]
                                      ]

                                      So the JSON application has to find the meaning of "abc:title", if it cares, like XML applications do by looking for the first enclosing element with
                                      a definition for "abc"?



                                      Thanks,

                                      Mark Joseph, Ph.D.
                                      President
                                      P6R, Inc
                                      408-205-0361
                                      mark@...
                                      Skype: markjoseph_sc
                                      _____

                                      From: stephen.mckamey [mailto:stephen@...]
                                      To: json@yahoogroups.com
                                      Sent: Tue, 06 Apr 2010 10:11:22 -0700
                                      Subject: [json] Re: Where our JSON product is heading: XML to JSON and Back








                                      JsonML ( http://jsonml.org ) handles all of these issues and has been embraced by quite a number of places. Many JSON encoders already include support.

                                      It handles namespaces the same way that XML 1.0 did: include the name as "prefix:local-name" and the URI to prefix mapping (xmlns:abc="http://example.com/abc") as the attribute of the node that declared it.

                                      An early implementation of JsonML took a similar approach to including a child object, but ultimately after some design discussions with Douglas Crockford, his suggestion was to make the actual element an array like the child object and have the element name be the first item.

                                      This positional structure has been the biggest part that people have disliked about JsonML, but yet in many XML documents (XHTML for example, being the primary use case) position of the child nodes is critical to the meaning of the document. So you get much smaller documents when you just add the element name as the first child and make elements arrays.

                                      I'd encourage you to embrace JsonML and contribute to a standard that has been around for four years already rather than creating a slightly different approach.

                                      --- In json@yahoogroups.com, "Mark Joseph" <mark@...> wrote:
                                      >
                                      > For people interested in this topic. We are always open to comments and questions.
                                      >
                                      > https://www.p6r.com/articles/2010/04/05/xml-to-json-and-back/
                                      >
                                      >
                                      > Best,
                                      >
                                      > Mark Joseph, Ph.D.
                                      > President
                                      > P6R, Inc
                                      > 408-205-0361
                                      > mark@...
                                      > Skype: markjoseph_sc
                                      >
                                      >
                                      >
                                      > [Non-text portions of this message have been removed]
                                      >




                                      [Non-text portions of this message have been removed]
                                    • Mark Joseph
                                      Ok I think I see how mixed content works in JsonML: hi there joe how are you becomes [ description ,
                                      Message 18 of 28 , Apr 6, 2010
                                      • 0 Attachment
                                        Ok I think I see how mixed content works in JsonML:

                                        <description lang="en-us"> hi there <bold>joe</bold> how are you </descrption>

                                        becomes

                                        [ "description", {"lang":"en-us"},
                                        " hi there ",
                                        [ "bold", "joe" ],
                                        " how are you "
                                        ]

                                        Is that right?


                                        Best,

                                        Mark Joseph, Ph.D.
                                        President
                                        P6R, Inc
                                        408-205-0361
                                        mark@...
                                        Skype: markjoseph_sc
                                        _____

                                        From: stephen.mckamey [mailto:stephen@...]
                                        To: json@yahoogroups.com
                                        Sent: Tue, 06 Apr 2010 10:20:12 -0700
                                        Subject: Re: SV: [json] JSON representation for XML snippet






                                        Not that ugly:

                                        ["node1", {"a":"45"},
                                        ["node2", {"b":"9", "c":"hithere"},
                                        ["node3", {"d":"abc"},
                                        ["node4", {"e":"12345"}, "JSON has no attributes"]
                                        ]
                                        ],
                                        "Now is the time for all good men to come to the aid of their party",

                                        ["node5", {"d":"45"}, "temperature is 70 degrees today"]
                                        ]

                                        --- 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
                                        >




                                        [Non-text portions of this message have been removed]
                                      • stephen.mckamey
                                        The attributes object is optional (see the BNF at http://jsonml.org) so you can drop it if empty to make more compact. The example XML:
                                        Message 19 of 28 , Apr 6, 2010
                                        • 0 Attachment
                                          The attributes object is optional (see the BNF at http://jsonml.org) so you can drop it if empty to make more compact.

                                          The example XML:

                                          <description abc="http://example.com">
                                          <abc:title>hi there</abc:title>
                                          </description>

                                          would encode in JsonML as:

                                          ["description", {"abc":"http://example.com"},
                                          ["abc:title", "hi there"]
                                          ]

                                          To encode mixed content, I think you mean like this:

                                          <div class="section">
                                          <p class="description">This is how <b>inline elements</b> get marked up.</p>
                                          </div>

                                          would encode to the JsonML:

                                          ["div", {"class":"section"},
                                          ["p", {"class":"description"}, "This is how ", ["b", "inline elements"], " get marked up."]
                                          ]

                                          Optionally, you could even encode the document whitespace as well if this was significant to the original XML.

                                          ["div", {"class":"section"},
                                          "\r\n\t",
                                          ["p", {"class":"description"}, "This is how ", ["b", "inline elements"], " get marked up."],
                                          "\r\n"
                                          ]

                                          --- In json@yahoogroups.com, "Mark Joseph" <mark@...> wrote:
                                          >
                                          > Cool stuff, can you show me an example of how JsonML handles XML mixed content, that is not clear to me from the web site.
                                          >
                                          >
                                          > And just so it is clear to me, the namespace example would be something like:
                                          >
                                          > <description abc="http://example.com"><abc:title>hi there</abc:title></description>
                                          >
                                          > becomes
                                          >
                                          > [ "description", {"abc" : "http://example.com"},
                                          > [ "abc:title", {}, "hi there" ]
                                          > ]
                                          >
                                          > So the JSON application has to find the meaning of "abc:title", if it cares, like XML applications do by looking for the first enclosing element with
                                          > a definition for "abc"?
                                          >
                                          >
                                          >
                                          > Thanks,
                                          >
                                          > Mark Joseph, Ph.D.
                                          > President
                                          > P6R, Inc
                                          > 408-205-0361
                                          > mark@...
                                          > Skype: markjoseph_sc
                                          > _____
                                          >
                                          > From: stephen.mckamey [mailto:stephen@...]
                                          > To: json@yahoogroups.com
                                          > Sent: Tue, 06 Apr 2010 10:11:22 -0700
                                          > Subject: [json] Re: Where our JSON product is heading: XML to JSON and Back
                                          >
                                          >
                                          >
                                          >
                                          >
                                          >
                                          >
                                          >
                                          > JsonML ( http://jsonml.org ) handles all of these issues and has been embraced by quite a number of places. Many JSON encoders already include support.
                                          >
                                          > It handles namespaces the same way that XML 1.0 did: include the name as "prefix:local-name" and the URI to prefix mapping (xmlns:abc="http://example.com/abc") as the attribute of the node that declared it.
                                          >
                                          > An early implementation of JsonML took a similar approach to including a child object, but ultimately after some design discussions with Douglas Crockford, his suggestion was to make the actual element an array like the child object and have the element name be the first item.
                                          >
                                          > This positional structure has been the biggest part that people have disliked about JsonML, but yet in many XML documents (XHTML for example, being the primary use case) position of the child nodes is critical to the meaning of the document. So you get much smaller documents when you just add the element name as the first child and make elements arrays.
                                          >
                                          > I'd encourage you to embrace JsonML and contribute to a standard that has been around for four years already rather than creating a slightly different approach.
                                          >
                                          > --- In json@yahoogroups.com, "Mark Joseph" <mark@> wrote:
                                          > >
                                          > > For people interested in this topic. We are always open to comments and questions.
                                          > >
                                          > > https://www.p6r.com/articles/2010/04/05/xml-to-json-and-back/
                                          > >
                                          > >
                                          > > Best,
                                          > >
                                          > > Mark Joseph, Ph.D.
                                          > > President
                                          > > P6R, Inc
                                          > > 408-205-0361
                                          > > mark@
                                          > > Skype: markjoseph_sc
                                          > >
                                          > >
                                          > >
                                          > > [Non-text portions of this message have been removed]
                                          > >
                                          >
                                          >
                                          >
                                          >
                                          > [Non-text portions of this message have been removed]
                                          >
                                        • stephen.mckamey
                                          Exactly. We were posting very similar examples at the same time. :)
                                          Message 20 of 28 , Apr 6, 2010
                                          • 0 Attachment
                                            Exactly. We were posting very similar examples at the same time. :)

                                            --- In json@yahoogroups.com, "Mark Joseph" <mark@...> wrote:
                                            >
                                            > Ok I think I see how mixed content works in JsonML:
                                            >
                                            > <description lang="en-us"> hi there <bold>joe</bold> how are you </descrption>
                                            >
                                            > becomes
                                            >
                                            > [ "description", {"lang":"en-us"},
                                            > " hi there ",
                                            > [ "bold", "joe" ],
                                            > " how are you "
                                            > ]
                                            >
                                            > Is that right?
                                            >
                                            >
                                            > Best,
                                            >
                                            > Mark Joseph, Ph.D.
                                            > President
                                            > P6R, Inc
                                            > 408-205-0361
                                            > mark@...
                                            > Skype: markjoseph_sc
                                            > _____
                                            >
                                            > From: stephen.mckamey [mailto:stephen@...]
                                            > To: json@yahoogroups.com
                                            > Sent: Tue, 06 Apr 2010 10:20:12 -0700
                                            > Subject: Re: SV: [json] JSON representation for XML snippet
                                            >
                                            >
                                            >
                                            >
                                            >
                                            >
                                            > Not that ugly:
                                            >
                                            > ["node1", {"a":"45"},
                                            > ["node2", {"b":"9", "c":"hithere"},
                                            > ["node3", {"d":"abc"},
                                            > ["node4", {"e":"12345"}, "JSON has no attributes"]
                                            > ]
                                            > ],
                                            > "Now is the time for all good men to come to the aid of their party",
                                            >
                                            > ["node5", {"d":"45"}, "temperature is 70 degrees today"]
                                            > ]
                                            >
                                            > --- 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
                                            > >
                                            >
                                            >
                                            >
                                            >
                                            > [Non-text portions of this message have been removed]
                                            >
                                          • Fredag_d13
                                            That looks pretty perfect to me. I think I will include JSONML support in the next release of my JSON api. Thanks to Mark Joseph for starting this discussion
                                            Message 21 of 28 , Apr 7, 2010
                                            • 0 Attachment
                                              That looks pretty perfect to me. I think I will include JSONML support in the next release of my JSON api.

                                              Thanks to Mark Joseph for starting this discussion and thank you Stephen for the JSONML pointer.

                                              I like the idea that no special characters such as @, # or stringpatterns are needed.

                                              /Jonas

                                              --- In json@yahoogroups.com, "stephen.mckamey" <stephen@...> wrote:
                                              >
                                              > Exactly. We were posting very similar examples at the same time. :)
                                              >
                                              > --- In json@yahoogroups.com, "Mark Joseph" <mark@> wrote:
                                              > >
                                              > > Ok I think I see how mixed content works in JsonML:
                                              > >
                                              > > <description lang="en-us"> hi there <bold>joe</bold> how are you </descrption>
                                              > >
                                              > > becomes
                                              > >
                                              > > [ "description", {"lang":"en-us"},
                                              > > " hi there ",
                                              > > [ "bold", "joe" ],
                                              > > " how are you "
                                              > > ]
                                              > >
                                              > > Is that right?
                                              > >
                                              > >
                                              > > Best,
                                              > >
                                              > > Mark Joseph, Ph.D.
                                              > > President
                                              > > P6R, Inc
                                              > > 408-205-0361
                                              > > mark@
                                              > > Skype: markjoseph_sc
                                              > > _____
                                              > >
                                              > > From: stephen.mckamey [mailto:stephen@]
                                              > > To: json@yahoogroups.com
                                              > > Sent: Tue, 06 Apr 2010 10:20:12 -0700
                                              > > Subject: Re: SV: [json] JSON representation for XML snippet
                                              > >
                                              > >
                                              > >
                                              > >
                                              > >
                                              > >
                                              > > Not that ugly:
                                              > >
                                              > > ["node1", {"a":"45"},
                                              > > ["node2", {"b":"9", "c":"hithere"},
                                              > > ["node3", {"d":"abc"},
                                              > > ["node4", {"e":"12345"}, "JSON has no attributes"]
                                              > > ]
                                              > > ],
                                              > > "Now is the time for all good men to come to the aid of their party",
                                              > >
                                              > > ["node5", {"d":"45"}, "temperature is 70 degrees today"]
                                              > > ]
                                              > >
                                              > > --- 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
                                              > > >
                                              > >
                                              > >
                                              > >
                                              > >
                                              > > [Non-text portions of this message have been removed]
                                              > >
                                              >
                                            • Mark Joseph
                                              We have also decided to support JsonML in our next product version Sent from my iPhone ... [Non-text portions of this message have been removed]
                                              Message 22 of 28 , Apr 7, 2010
                                              • 0 Attachment
                                                We have also decided to support JsonML in
                                                our next product version


                                                Sent from my iPhone

                                                On Apr 7, 2010, at 1:29 AM, "Fredag_d13" <jonas@...> wrote:

                                                > That looks pretty perfect to me. I think I will include JSONML
                                                > support in the next release of my JSON api.
                                                >
                                                > Thanks to Mark Joseph for starting this discussion and thank you
                                                > Stephen for the JSONML pointer.
                                                >
                                                > I like the idea that no special characters such as @, # or
                                                > stringpatterns are needed.
                                                >
                                                > /Jonas
                                                >
                                                > --- In json@yahoogroups.com, "stephen.mckamey" <stephen@...> wrote:
                                                > >
                                                > > Exactly. We were posting very similar examples at the same time. :)
                                                > >
                                                > > --- In json@yahoogroups.com, "Mark Joseph" <mark@> wrote:
                                                > > >
                                                > > > Ok I think I see how mixed content works in JsonML:
                                                > > >
                                                > > > <description lang="en-us"> hi there <bold>joe</bold> how are you
                                                > </descrption>
                                                > > >
                                                > > > becomes
                                                > > >
                                                > > > [ "description", {"lang":"en-us"},
                                                > > > " hi there ",
                                                > > > [ "bold", "joe" ],
                                                > > > " how are you "
                                                > > > ]
                                                > > >
                                                > > > Is that right?
                                                > > >
                                                > > >
                                                > > > Best,
                                                > > >
                                                > > > Mark Joseph, Ph.D.
                                                > > > President
                                                > > > P6R, Inc
                                                > > > 408-205-0361
                                                > > > mark@
                                                > > > Skype: markjoseph_sc
                                                > > > _____
                                                > > >
                                                > > > From: stephen.mckamey [mailto:stephen@]
                                                > > > To: json@yahoogroups.com
                                                > > > Sent: Tue, 06 Apr 2010 10:20:12 -0700
                                                > > > Subject: Re: SV: [json] JSON representation for XML snippet
                                                > > >
                                                > > >
                                                > > >
                                                > > >
                                                > > >
                                                > > >
                                                > > > Not that ugly:
                                                > > >
                                                > > > ["node1", {"a":"45"},
                                                > > > ["node2", {"b":"9", "c":"hithere"},
                                                > > > ["node3", {"d":"abc"},
                                                > > > ["node4", {"e":"12345"}, "JSON has no attributes"]
                                                > > > ]
                                                > > > ],
                                                > > > "Now is the time for all good men to come to the aid of their
                                                > party",
                                                > > >
                                                > > > ["node5", {"d":"45"}, "temperature is 70 degrees today"]
                                                > > > ]
                                                > > >
                                                > > > --- 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
                                                > > > >
                                                > > >
                                                > > >
                                                > > >
                                                > > >
                                                > > > [Non-text portions of this message have been removed]
                                                > > >
                                                > >
                                                >
                                                >


                                                [Non-text portions of this message have been removed]
                                              Your message has been successfully submitted and would be delivered to recipients shortly.