# \[WS\] JSON\_NORMALIZE. Manipulate JSON utility

**URL:** https://community.mp3tag.de/t/ws-json-normalize-manipulate-json-utility/51062
**Category:** Web Sources Discussion
**Created:** [December 7, 2020, 10:24am UTC](https://community.mp3tag.de/t/ws-json-normalize-manipulate-json-utility/51062 "2020-12-07T10:24:17Z")
**Posts on this page:** 5
**Page:** 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: [December 7, 2020, 10:24am UTC](https://community.mp3tag.de/t/ws-json-normalize-manipulate-json-utility/51062/1 "2020-12-07T10:24:17Z")

</div>

I have managed to create a "utility" JSON\_NORMALIZE.inc which can help WS authors manipulate JSON input stream (missing information, move info)

Features:

1. Wrap all keys between «» e.g. "«Companies»".  
Can be activated by populating temporary tag "JSON\_NORMALIZE\_KEY\_WRAP"  
outputto "JSON\_NORMALIZE\_KEY\_WRAP"  
say "yes" # any non blank value would work the same

2. Add all parent keys to each JSON key "Key1-Key2-Key3"  
Can be activated by populating temporary tag "JSON\_NORMALIZE\_KEY\_PATH"  
outputto "JSON\_NORMALIZE\_KEY\_PATH"  
say "yes" # any non blank value would work the same

3. Wrap values between ‟” inside double quotes, e.g. "‟Album”"  
This option is useful when searching/scanning certain values/value patterns.  
Careful when using this feature.  
if "" and ifnot "" might not bring desired results. Remove boundaries first before if condition.  
Can be activated by populating temporary tag "JSON\_NORMALIZE\_VALUE\_WRAP"  
outputto "JSON\_NORMALIZE\_VALUE\_WRAP"  
say "yes" # any non blank value would work the same

4. Add elements \_OBJECT\_BEGIN\_, \_OBJECT\_END\_ as first/last elements of an object ({})

5. Add elements \_ARRAY\_BEGIN\_, \_ARRAY\_END\_ as first/last elements of each object within array ({} within )

6. Add array ascending index to value of \_ARRAY\_BEGIN\_

7. Add element \_ARRAY\_LAST\_ELEMENT\_ (value "yes") at the last object of an array

Real Usages:

1. Certain JSON do not have Track numbers
2. Move Discogs credits into tracklist part (still working on it)
3. Full path key and/or key boundaries might help some people.  
e.g.

> ```
> json_foreach "«tracklist»"
> ifnot "0"
> json_foreach "«tracklist-extraartists»"
> ifnot "0"
> outputto "credits"
> json_select "«tracklist-extraartists-name»"
> sayrest
> say ", "
> endif
> endif
> json_foreach_end
> 
> ```

or (without path)

> ```
> json_foreach "«tracklist»"
> ifnot "0"
> json_foreach "«extraartists»"
> ifnot "0"
> outputto "credits"
> json_select "«name»"
> sayrest
> say ", "
> endif
> endif
> json_foreach_end
> 
> ```

Download **JSON\_NORMALIZE.inc** here [JSON\_NORMALIZE.zip](https://community.mp3tag.de/uploads/short-url/yXW4tScm8XOeX9gNAb67yJoUlJA.zip) (3.8 KB)  
A working example for VGMdb (calculate missing Tracks, Tracktotal, Disc number and TotalDiscs) [VGMdb#Search by &Album JSON Normalize.src](https://community.mp3tag.de/uploads/short-url/jX308nkuPFIi4oDM64ALzMThDQ0.src) (20.8 KB)

Update: If input Json is multiline a JoinLine NNNN command must be executed first.  
Any attempt with an arbitrary large number of lines (10000) fails the script. It has been addressed to Florian. Hopefully we will have some good news.  
Discogs returns single line Json.

---

<div class="post-metadata">

### Author: ![Romano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/romano/32/7465_2.png) [@Romano](https://community.mp3tag.de/u/Romano)
#### Post date: [December 7, 2020, 12:05pm UTC](https://community.mp3tag.de/t/ws-json-normalize-manipulate-json-utility/51062/2 "2020-12-07T12:05:00Z")

</div>

The involved people stopped working, in the example and any other album i press the album in the index it gives an error, or:

 ![](https://community.mp3tag.de/uploads/default/original/2X/d/dfff069cc91aa831adc711170f4a6d08b2ee46a8.png)

---

<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: [December 7, 2020, 12:43pm UTC](https://community.mp3tag.de/t/ws-json-normalize-manipulate-json-utility/51062/3 "2020-12-07T12:43:57Z")

</div>

@Romano please use the VGMdb script.  
I had initially uploaded a wrong version. It was updated 1h ago.  
I will download the uploaded script and test (just in case).  
The script is only one example (one fixed album from your VTGdb thread).  
Update: Your initial album link works well now. Indeed it was an issue with Involved people.  
Each JSON key includes the full path. This is fully customizable when executing JSON Normalizer.

---

<div class="post-metadata">

### Author: ![Romano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/romano/32/7465_2.png) [@Romano](https://community.mp3tag.de/u/Romano)
#### Post date: [December 7, 2020, 6:44pm UTC](https://community.mp3tag.de/t/ws-json-normalize-manipulate-json-utility/51062/4 "2020-12-07T18:44:00Z")

</div>

Thank you, i need time to absorve all of this. i am a newbie still.

---

<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: [December 15, 2020, 8:02am UTC](https://community.mp3tag.de/t/ws-json-normalize-manipulate-json-utility/51062/5 "2020-12-15T08:02:10Z")

</div>

v2.01 [JSON\_NORMALIZE\_v2.01.zip](https://community.mp3tag.de/uploads/short-url/4K76aJEyJkLP6fN3XIu6cXRqU5u.zip) (4.0 KB)
