JSON Parsing - Counting inside an array, not the array itself

Is it possible to have a counter in a json_foreach loop after selection of an object?

The reason I ask is I want to check the component after selecting it and if it says Release Track Listing then count each.

Here's the code snippet:

outputto "TOTALTRACKS"
json_foreach "tracks"
json_select "component"
if "Release Track Listing"

## Here is where I would like to count inside the if statement.

endif
json_foreach_end

That would be a nice feature.

I think this is feasible using the JSON_Normalize Tool I have recently developed.
The idea is original Json is parsed (as a pure string) and each tagname includes full path. All arrays are generated an ascending index from this tool (some WS do not have track position).
Based on above it is feasible (if you know upfront the <full path>tagname and condition) to introduce a counter only for those array objects.
Tool would make tagname "component" under "tracks" as "tracks˃component". Please note ˃ in the tag path is NOT the gt (>) character although they look the same.
Have a look on the script first.
You could add your additional logic after # END OF CONVERSION (around line 250) and before restore escaped characters.

1 Like

As Marty McFly says This is heavy..

Great work. :smiley: I don't think I have the time to add it to my beatport scripts.