This tool can be used to interconvert between JSON (JavaScript Object Notation) and XML content.
To convert a JSON string to XML, select the checkbox as shown below. The editor on the left represents the input JSON source that must be converted into XML and the editor on the right represents the output result in XML.

BadgerFish Notation Input
If the JSON string is in BadgerFish notation, then it can be converted to XML as is since the namespaces are already present in the JSON string.
The Options link can be used to configure the XML generation options: For JSON in BadgerFish (BF) notation, the option available is “Ignore whitespace”.
Consider the following JSON source that declares the namespaces as part
of the property names:
{"alice": {
"bob": {"$": "david"},
"charlie:edgar": {"$": "frank"},
"@xmlns": {
"$": "http://some-namespace",
"charlie": "http://some-other-namespace"
}
}}
The XML output when using BadgerFish convention is as shown below:
<alice xmlns="http://some-namespace" xmlns:charlie="http://some-other-namespace"><bob>david</bob><charlie:edgar>frank</charlie:edgar></alice>
If the input JSON string value has any whitespace characters like "\n" and the checkbox is enabled, then the generated XML will not have those whitespace characters present in the data.
Mapped Notation Input
For JSON in Mapped notation, the available configuration options are as shown below:
The option is as described above.
Consider the same example in mapped notation (where the prefix is present in the property, but the namespace URI is absent):
{"abc.alice":{"abc.bob":"david","xyz.edgar":"frank"}}
To convert this JSON input into XML using Mapped notation, we have the option of either specifying the namespace URI for the prefixes (abc and xyz) or leaving it unspecified. This is controlled through the option. If this option is disabled, then the Configure NS->Prefix Mapping table is enabled and we can specify the namespace URI -> Prefix mapping.
If the URI - Prefix mapping is done as follows:
Table 9.1. Namespace URI - Prefix mapping
| Namespace URI | Prefix |
|---|---|
| http://some-namespace | abc |
| http://some-other-namespace | xyz |
The generated XML output is as follows with this mapping in place:
<?xml version="1.0" encoding="UTF-8"?> <alice xmlns="http://some-namespace"> <bob>david</bob> <edgar xmlns="http://some-other-namespace">frank</edgar> </alice>
To convert an XML string to JSON, select the checkbox as shown below. The editor on the left represents the input XML source that must be converted into its equivalent JSON form and the editor on the right represents the output result in JSON.

Consider an input XML as given below that needs to be converted into JSON:
<?xml version="1.0" encoding="UTF-8"?> <alice xmlns="http://some-namespace" xmlns:charlie="http://some-other-namespace"> <bob>david</bob> <charlie:edgar>frank</charlie:edgar> </alice>
The above XML can be converted into JSON using either the BadgerFish notation or the Mapped notation. Clicking on the button opens the Conversion Options dialog as shown below:
BadgerFish notation output
When the checkbox is enabled, the only available configuration option is the checkbox, which if enabled, will ignore any whitespace characters present in the input XML document when generating the output JSON content. For the input XML above, the generated JSON string when using BadgerFish convention is as follows:
{"alice":{"@xmlns":{"$":"http:\/\/some-namespace","charlie":"http:\/\/some-other-namespace"},"bob":{"$":"david"},"charlie:edgar":{"$":"frank"}}}
Mapped notation output
When the checkbox is enabled, the configuration options are as shown below:
In the configuration dialog above, the option ignores the presence of any whitespace
characters in the input XML.
The option if enabled, will cause any data such as numbers to be detected as a number and output as such instead of a string. For e.g. if an element contains the value 10, then instead of outputting the value as "10", the JSON value will be output as 10.
The option if not enabled, allows you to declare the namespace to prefix mapping that should be applied when generating the JSON content. Note that even though the namespace URI is specified, the mapped convention does not allow for capturing the URI and only uses the prefix specified in the generated output. For the input XML above, the generated output is as follows with this option enabled:
{"alice":{"bob":"david","charlie.edgar":"frank"}}



Contents
Search
