Open bonatoc opened 8 years ago
I agree, good idea for next major release, thanks.
Object.getOwnPropertyNames(json)
Object.keys(json)
for(let key in json) {
// ...
}
will do the thing - no need for changing the structure
It is also easy to iterate over with foreach()
in php
, of course after a json_decode()
, so I guess the format stays.
@ckwagaba There is https://github.com/umpirsky/country-list/blob/master/data/en/country.php for PHP. No need to json decode.
How did I miss that? Thanks for that.
this new format is usefull only if it contains some other data for example flag or list of locales
Object.getOwnPropertyNames(json) Object.keys(json) for(let key in json) { // ... }
will do the thing - no need for changing the structure
Or you could use Object.entries
example:
Object.entries(json).map(([key, value]) => key + " - " + value);
No seriously. The format of the JSON data is absolutely horrific. Why would anyone think this is a good idea?
With JS frameworks, and more generally REST APIs/HTTP requests, the current JSON structures are not much help, since we can't programmatically target keys.
How about this structure?