[F] json API "catch" missing tag

I started using the new Websource json approach. It is lovely. I found an issue (not necessary from mp3tag) and trying to find a solution.
Websource script ends with an error when searching for omitted tag of the API response (e.g. this discogs release does not have any Style).
With "traditional" webscript we could bypass this issue by adding 1 parameter (goto first character of the row in case of search failure).
Do we have any similar solution with json now?
If not then we have to add omitted tags to stream before starting json parsing to avoid all possible failures. Not an easy task. Can be very tricky.

Hi Victor,

thanks for your feedback! Glad you like the new JSON-related functions :slight_smile:

I was thinking about the issue you're describing and what I would like the most is to make the functions error-safe in a way that, e.g., json_select_array would simply return nothing in case the given key does not refer to an array.

Using this approach, we can still check for any content using
ifnot ""

What do you think?

Kind regards

I was so desperate about (missing) json parsing I wrote a very complex regexp script to convert json stream to pseudo xml format. Each element name included the whole path
(e.g. "Format->Description", "Tracklist->Artist->Name", etc).

I like it!!!!!! I see no reason anyone would complain. As soon as the script does not fail all is good.
Actually I had seen ifnot "" statement in the official json discogs script but couldn't find an explanation of its presence :-).

Kind regards,

I noticed something else (I found a workaround) which is "caused" by the URL-UTF-8 encoding.
API fails when using complex search (multiple parameters on the placeholder %s). That's because URL-UTF-8 encodes the ampersand character (&).
I replaced encoding with UTF-8 and complex search is back to life again.

Please consider some websript suggestions (in this new topic).
Please strogly consider point 4. I just realized we will lose "Advanced scripting" tricks by using json.
Using "traditional" scripting we were collecting information on the selected API stream (use regexp, etc) and storing it to temporary tags, e.g. scan all tracks to find total number of discs to make it available to all tracks (in a new tracks loop).

I believe introducing a command (unless already there???) to move an output value back to selected API stream value would cover many of our needs and make json with only PROS against traditional scripting. Now it has a big showstopper for advanced scripting.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.