Page 1 of 1

Inconsistency in JSON response

Posted: Wed Dec 07, 2016 12:20 pm
by nisseknudsen
Dear OPS team,

while working the API in JSON response format, I encountered a problem, and maybe you could fix it somehow in a future API version:

I access the published-data/search/biblio endpoint and query publications related to certain applicant names.
If a publication has one ipcr class assigned, the response is like following:

Code: Select all

"classifications_ipcr": {
                  "classification_ipcr": {
                    "x_sequence": "1",
                    "text": {
                      "$": "G05B                       C I"
                    }
                  }
                }
The "classification_ipcr" attribute has a JSON object as value.

If a publication has more than one ipcr class assigned, the response is like following:

Code: Select all

"classifications_ipcr": {
                  "classification_ipcr": [
                    {
                      "x_sequence": "1",
                      "text": {
                        "$": "F16D  13/    64            A I"
                      }
                    },
                    {
                      "x_sequence": "2",
                      "text": {
                        "$": "F16D  13/    72            A I"
                      }
                    }
                  ]
                }
You see, the type for "classification_ipcr" is now an array of objects.

This is a problem for automated parsing with schemas in my code. I think this is very inconsistent, and that the first response should be an array with length 1.

Is this something you would be able to address in future versions?

Thanks,

Nisse

Re: Inconsistency in JSON response

Posted: Wed Dec 07, 2016 10:19 pm
by EPO / OPS Support
Thank you very much, I will definitly forward your request to our developers.

Regards,

OPS support

Re: Inconsistency in JSON response

Posted: Sun Jan 15, 2017 1:53 pm
by jc275
Although @nisseknudsen mentions classifications, this is in fact a more general issue related to conversion from XML to JSON format. It affects all parts of the JSON response that may contain an array.

When the JSON response is based on XML data of the form,

Code: Select all

<items>
    <item>1</item>
    <item>2</item>
</items>
the JSON will contain an array,

Code: Select all

{ "items" : { "item" : [ "1" , "2" ] } }
but when there is only one <item> in the list, the JSON will not contain an array.

Code: Select all

{ "items" : { "item" : "1" } }

Re: Inconsistency in JSON response

Posted: Mon Jan 16, 2017 7:43 am
by EPO / OPS Support
Thank you, we will forward your request to out IT.

Regards,
OPS support

Re: Inconsistency in JSON response

Posted: Tue Feb 21, 2017 2:13 pm
by nisseknudsen
jc275 wrote:Although @nisseknudsen mentions classifications, this is in fact a more general issue related to conversion from XML to JSON format. It affects all parts of the JSON response that may contain an array.

When the JSON response is based on XML data of the form,

Code: Select all

<items>
    <item>1</item>
    <item>2</item>
</items>
the JSON will contain an array,

Code: Select all

{ "items" : { "item" : [ "1" , "2" ] } }
but when there is only one <item> in the list, the JSON will not contain an array.

Code: Select all

{ "items" : { "item" : "1" } }
@jc275, yes, you are right. I mentioned just some examples that I stumbled upon at that time, but it showed that this exists for every attribute that can have 0:many values.

Re: Inconsistency in JSON response

Posted: Wed Feb 22, 2017 1:25 pm
by EPO / OPS Support
Hi,
Please see the reply from our developers:
This is known issue but we do not plan to change our response because that would impact all OPS JSON responses.

In a nutshell, in order to generate json from xml OPS uses so called Badger-Fish notation http://badgerfish.ning.com/ which states:

“Nested elements become nested properties” but “Multiple elements at the same level become array elements” therefore when there is one element, it is property displayed but in case of multiple elements it is an array"
Regards,
OPS support