Open EdwardBetts opened 6 years ago
That's a known issue which cannot be solved without breaking existing clients. So something for the next version of the API.
Hey EdwardBetts, could you maybe further explain, why the order is significant? In the example it seems, like every key appears exactly ones. Regards, Jens
@JensHumrich The elements in the address detail are ordered from most specific to general, ending with the largest geographical unit. JSON parsers will load the address detail into an associative array which isn't guaranteed to maintain the order of the keys.
I hope that answers your questions.
The JSON specification defines an object is an unordered set of name/value pairs.
The order of the address detail elements returned by nominatim is significant. JSON parsing libraries don't preserve the order of keys in an object.
Here is an example: http://nominatim.openstreetmap.org/details.php?place_id=22349856
XML is different, the order of tags is preserved by XML libraries.
Using a list of lists in JSON would keep the order of the address details. Here is the example reworked.