question

netsimple1 avatar image
0 Likes"
netsimple1 asked

Why does search return JSON items as array?

When calling findItemsAdvanced with RESPONSE-DATA-FORMAT=XML, the results are as expected, e.g: Success 1.13.0 2014-11-16T20:59:57.588Z 0 100 0 0 http://www.ebay.co.uk/sch/i.html?_nkw=mytest1 But calling the same with RESPONSE-DATA-FORMAT=JSON, individual elements are all wrapped in []: {"findItemsAdvancedResponse":[ {"ack":["Success"], "version":["1.13.0"], "timestamp":["2014-11-16T20:58:14.639Z"], "searchResult":[ {"@count":"0"}], "paginationOutput":[ {"pageNumber":["0"], "entriesPerPage":["100"], "totalPages":["0"], "totalEntries":["0"]}], "itemSearchURL":["http:\/\/ www.ebay.co.uk\/sch\/i.html?&_nkw=mytest1"] }] } This seems to make it a pain to extract results using Javascript e.g: response.findItemsAdvancedResponse[0].paginationOutput[0].pageNumber[0] Am I missing something here or doing something wrong?
search-apijsonarray
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

netsimple1 avatar image
0 Likes"
netsimple1 answered
**Note:** this question was originally asked on Stack Overflow but there was no suggested solution http://stackoverflow.com/questions/26962397/ebay-finding-api-json-result-elements-are-all-arrays
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

clickimusprime avatar image
0 Likes"
clickimusprime answered
There is no control input to correct this. It is what it is. and it is not ideal. eBay unnecessarily wrapped many single variables as array objects in the JSON output of the Finding API when it was created.
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

maccurt2014 avatar image
0 Likes"
maccurt2014 answered
Does this cause a problem when you try to deserialize it. I tried it in C# with newtonsoft and it did not work.
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

lastr_shau avatar image
0 Likes"
lastr_shau answered
It's time to play, GUESS THAT SCHEMA! You're better off taking the XML and converting it yourself. explicitArray: false
10 |600

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.