# Working with weather station data JSON

**URL:** https://discourse.nodered.org/t/working-with-weather-station-data-json/74929
**Category:** General
**Created:** [9 February 2023 04:28 UTC](https://discourse.nodered.org/t/working-with-weather-station-data-json/74929 "2023-02-09T04:28:29Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![HobbyFarmer](https://avatars.discourse-cdn.com/v4/letter/h/779978/32.png) [@HobbyFarmer](https://discourse.nodered.org/u/HobbyFarmer)
#### Post date: [9 February 2023 04:28 UTC](https://discourse.nodered.org/t/working-with-weather-station-data-json/74929/1 "2023-02-09T04:28:29Z")

</div>

What is the best way to pull say the temperature out of this JSON object and drop it into msg.payload. So far the examples I have found are more down the line of multiple devices all sending temperature and separating out the separate devices.

```auto
{"observations":[{"stationID":"ISTORE","obsTimeUtc":"2023-02-09T04:20:01Z","obsTimeLocal":"2023-02-08 22:20:01","neighborhood":"Ste. Anne","softwareType":"AMBWeatherV4.2.6","country":"CA","solarRadiation":0.2,"lon":-76.08,"realtimeFrequency":null,"epoch":16401,"lat":47.633,"uv":0,"winddir":10,"humidity":96,"qcStatus":-1,"imperial":{"temp":30,"heatIndex":30,"dewpt":30,"windChill":26,"windSpeed":5,"windGust":6,"pressure":29.02,"precipRate":0,"precipTotal":0.03,"elev":247}}]}

```

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [9 February 2023 05:20 UTC](https://discourse.nodered.org/t/working-with-weather-station-data-json/74929/2 "2023-02-09T05:20:14Z")

</div>

The documentation describes [how to work with messages](https://nodered.org/docs/user-guide/messages).

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [9 February 2023 09:56 UTC](https://discourse.nodered.org/t/working-with-weather-station-data-json/74929/3 "2023-02-09T09:56:29Z")

</div>

Feed the data into a debug node, then you can explore it's structure.  
There is a "Copy path" button which in this example gives "payload.observations[0].imperial.temp"

 ![Untitled 2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/7/6712cb0e3ca569ffa554802e4fb4287423d01284.jpeg)

---

<div class="post-metadata">

### Author: ![HobbyFarmer](https://avatars.discourse-cdn.com/v4/letter/h/779978/32.png) [@HobbyFarmer](https://discourse.nodered.org/u/HobbyFarmer)
#### Post date: [10 February 2023 01:14 UTC](https://discourse.nodered.org/t/working-with-weather-station-data-json/74929/4 "2023-02-10T01:14:51Z")

</div>

I hadn't realized this earlier.

I built a function node with

```auto
var temp = msg.payload.observations[0].imperial.temp

msg.payload = temp;
return msg;

```

in hopes that it would change the new payload to the temperature. In stead it give an error

```auto
TypeError: Cannot read properties of undefined (reading '0')

```

EDIT: This does work my wire was to the wrong place.

---

<div class="post-metadata">

### Author: ![HobbyFarmer](https://avatars.discourse-cdn.com/v4/letter/h/779978/32.png) [@HobbyFarmer](https://discourse.nodered.org/u/HobbyFarmer)
#### Post date: [10 February 2023 01:18 UTC](https://discourse.nodered.org/t/working-with-weather-station-data-json/74929/5 "2023-02-10T01:18:17Z")

</div>

Ok I got it, it works as expected. I looked closer and the wire was direct from the inject node and not going through the http request node.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [24 February 2023 01:18 UTC](https://discourse.nodered.org/t/working-with-weather-station-data-json/74929/6 "2023-02-24T01:18:39Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
