Tag Info

New answers tagged

3

refering to my answer your other question here is how you can get a table of e.g. coordinates and temperature from your example data (adopt to your needs): url = "http://api.openweathermap.org/data/2.5/find?lat=55.5&lon=37.5&cnt=10"; data = Import[url,"JSON"] //. x : {__Rule} :> Association[x]; Map[ (# @@@ {{"coord","lat"}, {"coord","lon"}, ...


6

JSON stands for JavaScript Object Notation. In JavaScript, and hence in JSON, the ordering of dictionary keys is not determined, and not meaningful. Thus Mathematica's behaviour is correct. From the JavaScript language specification, An Object is an unordered collection of properties. Each property consists of a name, a value and a set of attributes. ...


2

I like to use Cases with HoldPattern for these types of structures: Cases[out, HoldPattern["location" -> latlon_] :> {latlon[[1, 2]], latlon[[2, 2]]}, Infinity] {{48.3559, 10.8946}, {48.3747, 10.8957}}


5

With Mathematica 10 or later, I recommend converting this data structure to either an Association or a Dataset: asc = Replace[out, r : {__Rule} :> Association[r], {0, Infinity}]; ds = Dataset[asc] Then you can index it with the keys, e.g. asc[["results", 1, "geometry"]] (* <|"location" -> <|"lat" -> 48.35593, "lng" -> ...


1

Here's a workaround until this gets fixed. WARNING: Modifying installation files can break things. Do this at your own risk, and keep the modification in mind, in case you experience problems with JSON export later. Do this only if you are affected by the problem. Open the file SystemFiles`Links`JSONTools`JSONTools.m Skip to line 233, where the number ...



Top 50 recent answers are included