I would like to add multiple values to the same variable in a loop (separated by a slash) from this JSON data:
Currently, I know 2 ways to do that:
json_select_many which works perfectly fine for the
json_select_object "label-info" outputto "CATALOGNUMBER" json_select_many "label-info" "catalog-number" " / " sayrest json_unselect_object
and results in the expected
LR-1893008 / LR-1893008
Unfortunately, I don't get this working for the disambiguations
json_select in the example for the PUBLISHER where I want to add the disambiguation in parenthesis
outputto "PUBLISHER" json_foreach "label-info" json_select "label" json_select "name" sayrest json_select "disambiguation" ifnot "" say "(" sayrest say ")" say " / " # Always add a Space and Slash and Space at the end of the output endif json_foreach_end
In this case, the PUBLISHER content always ends with a "
a) I don't know an indicator when the last iteration in the loop appears
b) I also don't know how I could increase a counter by +1 for every iteration
c) I don't get the max number of iterations (also known as max number of objects/elements) which I could compare to the current iteration
How do you solve this?