XML to JSON Conversion at convertjson.com

Q

How to use the XML to JSON Conversion Tool at convertjson.com?

✍: FYIcenter.com

A

If you want to try the XML to JSON Conversion Tool at convertjson.com, you can follow this tutorial:

1. Go to the JSON and XML Conversion Tool page at convertjson.com.

2. Enter the following XML document in the XML text area:

<profile id="10001">
   <name>John<mid>M</mid>Smith</name>
   <age>25</age>
   <address>
      <street>21 2nd Street</street>
      <city>New York</city>
   </address>
   <phone type="home">212 555-1234</phone>
   <phone type="office">646 555-4567</phone>
   <children/>
</profile>

3. Click the "Convert XML To JSON" button to convert it to JSON. You see the following output near the bottom:

{
   "profile": {
      "name": {
         "mid": "M",
         "__text": "John\nSmith",
         "toString": [
            null
         ]
      },
      "age": "25",
      "address": {
         "street": "21 2nd Street",
         "city": "New York"
      },
      "phone": [
         {
            "_type": "home",
            "__text": "212 555-1234",
            "toString": [
               null
            ]
         },
         {
            "_type": "office",
            "__text": "646 555-4567",
            "toString": [
               null
            ]
         }
      ],
      "children": "",
      "_id": "10001"
   }
}

Note that the conversion used some implicit rules:

  • An XML attribute is converted into a JSON name and value pair, with "_" added to the attribute name.
  • Repeating XML elements are converted into a JSON Array.
  • "__text" is used to name XML text content, if needed.
  • Scattered text contents are concatenated to a single JSON String.
  • "toString": [null] is incorrectly added to some XML elements for no reason.

So the XML to JSON conversion tool at convertjson.com is not good, because it adds extra "toString": [null] properties.

The picture below shows you how to use the online XML to JSON conversion tool at convertjson.com:
XML to JSON Conversion: convertjson.com

 

XML to JSON Conversion

⇒⇒JSON Tutorials

2017-08-14, 119👍, 0💬