Parse a random json

Hi,

When i do a http get from my solaredge system, i get a json array with types and values.
But the types are on random object places, how can i parse them ?

2 things needed to help you...

  1. What is the structure of the output you expect after re-arraning the data?
  2. Paste a sample of data (screenshots cannot be copied into a flow)
    image

And paste the value between backticks
```
[paste the json copied from the payload like this ]
```

{"energyDetails":{"timeUnit":"DAY","unit":"Wh","meters":[{"type":"SelfConsumption","values":[{"date":"2021-03-23 00:00:00","value":6127}]},{"type":"Purchased","values":[{"date":"2021-03-23 00:00:00","value":3353}]},{"type":"FeedIn","values":[{"date":"2021-03-23 00:00:00","value":7555}]},{"type":"Production","values":[{"date":"2021-03-23 00:00:00","value":13682}]},{"type":"Consumption","values":[{"date":"2021-03-23 00:00:00","value":9480}]}]}}

I need the value of each type.

Thanks...

Hi, try this jsonata expression in a change node

payload.energyDetails.meters.${type: values[*].value}
[{"id":"d49226ac.7ebd","type":"inject","z":"5a245aa1.510164","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"energyDetails\":{\"timeUnit\":\"DAY\",\"unit\":\"Wh\",\"meters\":[{\"type\":\"SelfConsumption\",\"values\":[{\"date\":\"2021-03-23 00:00:00\",\"value\":6127}]},{\"type\":\"Purchased\",\"values\":[{\"date\":\"2021-03-23 00:00:00\",\"value\":3353}]},{\"type\":\"FeedIn\",\"values\":[{\"date\":\"2021-03-23 00:00:00\",\"value\":7555}]},{\"type\":\"Production\",\"values\":[{\"date\":\"2021-03-23 00:00:00\",\"value\":13682}]},{\"type\":\"Consumption\",\"values\":[{\"date\":\"2021-03-23 00:00:00\",\"value\":9480}]}]}}","payloadType":"json","x":120,"y":3140,"wires":[["23fa069.a74dd7a"]]},{"id":"23fa069.a74dd7a","type":"change","z":"5a245aa1.510164","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.energyDetails.meters.${type: values[*].value}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":3160,"wires":[["f396fc64.ed7c2"]]},{"id":"f396fc64.ed7c2","type":"debug","z":"5a245aa1.510164","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":560,"y":3180,"wires":[]}]

Thanks !!

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