# XML to JSON

**URL:** https://community.mp3tag.de/t/xml-to-json/16299
**Category:** Web Sources Discussion
**Created:** [November 7, 2014, 5:57pm UTC](https://community.mp3tag.de/t/xml-to-json/16299 "2014-11-07T17:57:57Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![vkostas](https://community.mp3tag.de/user_avatar/community.mp3tag.de/vkostas/32/227_2.png) [@vkostas](https://community.mp3tag.de/u/vkostas)
#### Post date: [November 7, 2014, 5:57pm UTC](https://community.mp3tag.de/t/xml-to-json/16299/1 "2014-11-07T17:57:57Z")

</div>

JSON is the first mp3tag proper WSS parser.  
I managed to convert XML to JSON by only using regular expressions.  
It covers all complex structures, attributes, comments, CDATA, namespaces.  
And yes, it is written from scratch.  
One thing convertor cannot know is if XML tags with single appearance are subject to array.

```
<disc number="1">
<track number="1">Innuendo</track>
<track number="2">One vision</track>
</disc>

```

Both disc and track are array elements but only track appears multiple times.  
There is a solution for this:

1. Convert everything to array
2. Pass the script the list of array tags

XML to JSON conversion cannot be used yet - JSON mode parses only the original stream - but hopefully it will be soon available (Florian, I am patient :wink:).

I attach two pairs of XML-JSON files (pretty printer applied to all 4 files in notepad++).

[Queen\_Platinum\_Collection.xml](https://community.mp3tag.de/uploads/default/original/2X/a/af06ac79622f2d2e989fef89d53a429d1bf1b6ac.xml) (9.73 KB)

[Pink\_Floyd\_Discovery.xml](https://community.mp3tag.de/uploads/default/original/2X/0/0661dbadcd33147d073a0229ba74920f5bc1d5e0.xml) (30 KB)

[Queen\_Platinum\_Collection.json.txt](https://community.mp3tag.de/uploads/default/original/2X/a/ae00eca0e677f5df6458a3178e85210af8f5bd12.txt) (14.4 KB)

[Pink\_Floyd\_Discovery.json.txt](https://community.mp3tag.de/uploads/default/original/2X/8/80d42736cb2b0b10c75ffad1e882771e50f27316.txt) (50.9 KB)

---

_[View the full topic](https://community.mp3tag.de/t/xml-to-json/16299)._
