Inconsistency in JSON response

This space is made available to users of Open Patent Services (OPS) web-service and now also to users of EPO’s bulk data subscription products such as 14. EPO worldwide bibliographic database (DOCDB), 14.11 EPO worldwide legal status database (INPADOC), 14.12 EP full text data, 14.1 EP bibliographic data (EBD)and more.

Users can ask each other questions, exchange experiences and solutions, post ideas. The moderator will use this space to announce changes or other relevant information.
Post Reply

nisseknudsen
Posts: 6
Joined: Wed Dec 07, 2016 12:10 pm

Inconsistency in JSON response

Post by nisseknudsen » Wed Dec 07, 2016 12:20 pm

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


EPO / OPS Support
Posts: 1298
Joined: Thu Feb 22, 2007 5:32 pm

Re: Inconsistency in JSON response

Post by EPO / OPS Support » Wed Dec 07, 2016 10:19 pm

Thank you very much, I will definitly forward your request to our developers.

Regards,

OPS support


jc275
Posts: 8
Joined: Sun Jul 24, 2016 8:02 pm

Re: Inconsistency in JSON response

Post by jc275 » Sun Jan 15, 2017 1:53 pm

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" } }
Last edited by jc275 on Thu Jan 26, 2017 1:50 am, edited 1 time in total.


EPO / OPS Support
Posts: 1298
Joined: Thu Feb 22, 2007 5:32 pm

Re: Inconsistency in JSON response

Post by EPO / OPS Support » Mon Jan 16, 2017 7:43 am

Thank you, we will forward your request to out IT.

Regards,
OPS support


nisseknudsen
Posts: 6
Joined: Wed Dec 07, 2016 12:10 pm

Re: Inconsistency in JSON response

Post by nisseknudsen » Tue Feb 21, 2017 2:13 pm

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.


EPO / OPS Support
Posts: 1298
Joined: Thu Feb 22, 2007 5:32 pm

Re: Inconsistency in JSON response

Post by EPO / OPS Support » Wed Feb 22, 2017 1:25 pm

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


Post Reply