Author |
Message |
17/09/2014 07:50:48
|
squeaky-clean
Joined: 16/09/2014 17:46:54
Messages: 2
Offline
|
Hi there, I noticed while using the Country Subdivision Web Service that that the JSON web service will not send more than one row, but the XML web service will. This is with radius and maxRows set.
Here is an example:
http://api.geonames.org/countrySubdivisionJSON?lat=47.03&lng=10.2&maxRows=10&radius=40&username=demo
http://api.geonames.org/countrySubdivision?lat=47.03&lng=10.2&maxRows=10&radius=40&username=demo
The same query, the normal service returns several rows, but the JSON service will only return one. I'm only analyzing this through my browser (Chrome, Win7) at the moment, but I don't believe that has anything to do with it.
Am I wrong, and the browser is just hiding the rest of the JSON? Or should I use the XML web services if I need multiple results returned.
Thanks.
|
|
|
17/09/2014 08:01:25
|
marc
Joined: 08/12/2005 07:39:47
Messages: 4412
Offline
|
This has historical reasons. The service first returned only one result. Later it was extended to return multiple results. For the xml response it was possible to add additional elements whereas for the json response it was not possible since the result json attributes were not wrapped in a container object.
We could change the response format when the maxRows param is present into an array of objects, but still it would break applications using the maxRows parameter even though it only returns one feature.
Regards
Marc
|
|
|
|
19/09/2014 11:28:20
|
squeaky-clean
Joined: 16/09/2014 17:46:54
Messages: 2
Offline
|
Thanks, marc, that's good to know. Are there any other web services that respond differently between XML and JSON? Maybe you could add a small note to the documentation page stating that the JSON service behaves this way.
I understand the problem with breaking applications, it's not something that's very easily solved. It wasn't too difficult to add an XML deserializer to my application, so I believe I'll just choose the XML formatted services when possible.
Thanks again,
squeaky
|
|
|
|