Isrcs json return type

is there any good reason that sometimes isrcs are returned as an array of objects with a value of strings
“isrcs”:[{“id”:“GBAMC9900024”}]

and sometimes an array of strings:
“isrcs”:[“GB01A0801425”,“GBCHB9810013”]

ive found both these on browse type requests

I have not converted my 5 year old perl scripts over to json yet but found with xml I needed to do a type check on a object that could return more than one value. I found a single item was “generally” returned as a scalar and multiple values were returned as a hash or array depending on the object I was processing.

Thing is in json both these are multiple value objects… one is a key value pair and the other is just the value understanding that “id” is unneeded info in the context.

what i should have given as an example
“isrcs”:[{“id”:“GBAMC9900024”}, {“id”:“GBAMC9900025”}]
rather than
“isrcs”:[{“id”:“GBAMC9900024”}]

But i didn’t want to try and write json syntax by hand as its easy to make mistakes and throw confusion in the discussion…

Anyway my application is crapping out at random places and ive traced the problem down to the isrcs, having trouble breaking down exactly when one is returned or the other is.

It just seems to me as an entirely unnecessary oversite.

Also if it was meant to be singular wouldnt the property be just isrc with no s

Can you give an example of requests that gave you these results? All requests I usually do return the second form, I don’t know which kind of request gives you the first one.

Sure.
Firstly let me make one correction I am only finding the kvp form in “Search” request and and not both forms in the Browse requests as I initially reported.
Browse and Lookup requests (afaik) do only return the array of values form.

http://musicbrainz.org/ws/2/recording/?query="Blow%20Your%20Mind"&fmt=json

Here in each returned recording you will find each isrc in the kvp form.

Sort of less a problem as its isolated to only one of the 3 types of requests, but still would be nice to share the same code

OK, so it’s an inconsistency between the JSON search API and the lookup/browse one in ws/2/ (the XML look similar though).

Can you open a ticket in
https://tickets.metabrainz.org/projects/MBS?

fwiw ticket was opened and this issue has been fixed

1 Like