Json "nesting" - extracting key data

A url containing my API for some solar panels returns the following:

{"overview":{"lastUpdateTime":"2020-09-30 14:19:23","lifeTimeData":{"energy":1165545.0,"revenue":248.58372},"lastYearData":{"energy":1129885.0},"lastMonthData":{"energy":453504.0},"lastDayData":{"energy":4867.0},"currentPower":{"power":441.279},"measuredBy":"INVERTER"}}

From googling I believe that it is "nested", and because of this it can't be processed by a "Magic Mirror" module. Can I use NR to clean / tidy / extract just the data that I want (for example lastDayData:4867.0), and if so how might I do this?

So far I have a TimeStamp > http In (outputting a parsed JSON object) > json (converting to JSON string) > debug. But (not surprisingly) this outputs the full string.

How might I extract bits out of the string?

TIA

example using change node

[{"id":"91be1257.55f2","type":"inject","z":"4484ee28.caa3c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"overview\":{\"lastUpdateTime\":\"2020-09-30 14:19:23\",\"lifeTimeData\":{\"energy\":1165545.0,\"revenue\":248.58372},\"lastYearData\":{\"energy\":1129885.0},\"lastMonthData\":{\"energy\":453504.0},\"lastDayData\":{\"energy\":4867.0},\"currentPower\":{\"power\":441.279},\"measuredBy\":\"INVERTER\"}}","payloadType":"json","x":150,"y":400,"wires":[["bce2a43b.35904"]]},{"id":"bce2a43b.35904","type":"change","z":"4484ee28.caa3c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.overview.lastDayData","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":400,"wires":[["269a25ff.79887a"]]},{"id":"269a25ff.79887a","type":"debug","z":"4484ee28.caa3c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":640,"y":340,"wires":[]}]
1 Like

Delete the JSON node and follow this...

https://nodered.org/docs/user-guide/messages

1 Like

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