GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
JSON Web Services returning different results  XML
Forum Index -> General
Author Message
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.
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

[WWW]
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
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team