APIs & parsing JSON etc

For several months I have been scraping my Powerwall SoC data via an API within Node-RED, and then graphing the output within emonCMS. Works brilliantly.

I would like to do something similar with some Solcast solar data - both Actual and later, Forecast. I have two “personal” APIs - one for each feed. I have copy / pasted the entire Powerwall Node-RED flow, substituting a local IP based API for an external url. The flow throws up an API Failed RC=200 error in the emonCMS node. In the debug window it says …

Node: solcast
msg: string[16]
“JSON parse error”

I have made no changes to this node, so presumably it is the previous node that is causing the issue. Sorry to be dim (once again), but how might I resolve this?


In case it helps, herewith a snippet from what the API returns in a browser.


How might I parse this, or does the software do it automatically? (Presumably not!).

This is probably a better starting point.

@haffle, I had a few problems with getting the Solcast data into emonCMS and ended up doing it via a small python script. But if I recall correctly, there were (at least) two problems. One was a misformed JSON object (a single comma or bracket…) and the other was - I think - trying to pass off an integer as a string. Does your Node-red debug node output the full JSON object in the debug window? Also there is a tick box in the json node “Format JSON string” - mine needed to be ticked.
If you can get the debug node to output the full json object that helps greatly in debugging.

1 Like