Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #32171
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: traverse a complex object and find value |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | <aea7f57c-56e8-4fe3-9804-68eacec8f7d8@googlegroups.com> |
| Date | 2017-01-12 09:36 +0100 |
| Message-ID | <XnsA6FB61CB35FE2eejj99@194.109.6.166> (permalink) |
jykl608@gmail.com wrote on 12 Jan 2017 in comp.lang.javascript:
> // START ==============================================
>
> {
> "coord": {
> "lon": -123.12,
> "lat": 49.25
> },
> "weather": [
> {
> "id": 800,
> "main": "Clear",
> "description": "clear sky",
> "icon": "01d"
> }
> ],
> "base": "stations",
> "main": {
> "temp": 272.22,
> "pressure": 1006,
> "humidity": 67,
> "temp_min": 266.15,
> "temp_max": 275.15
> },
> "visibility": 16093,
> "wind": {
> "speed": 3.1,
> "deg": 40
> },
> "clouds": {
> "all": 1
> },
> "dt": 1484177700,
> "sys": {
> "type": 1,
> "id": 1112,
> "message": 0.2153,
> "country": "CA",
> "sunrise": 1484150629,
> "sunset": 1484181512
> },
> "id": 6173331,
> "name": "Vancouver",
> "cod": 200
>}
>
> // END ================================================
>
> I want to find the value of "temp" inside the "main" property, but I am
> not sure how.
If the above is seen as a string "s":
var jsn = JSON.parse(s);
document.write(jsn.main.temp); // 272.22
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
traverse a complex object and find value jykl608@gmail.com - 2017-01-11 22:51 -0800 Re: traverse a complex object and find value "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-12 09:36 +0100 Re: traverse a complex object and find value Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-12 12:42 +0000 Re: traverse a complex object and find value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-13 21:48 +0100
csiph-web