0 votes
in ESPaper by (120 points)
Hi,

the weatherstation for ESPaper is great, but the Wunderground client is quite specific and already big. There's other client in the source, but they seem somehow unfinished or again customized for some specific use.

What would be the best, correct (ie. closing properly, avoiding consuming ressources, using streaming to be gentle on memory, etc.) simple JSON client to start with.

For example, if I want to add a single source JSON source to the weatherstation base and show some value, what client example code would you suggest I base my code on?

In a way, I'm asking if there's the equivalent of jQuery.getJson that we could use: simple, stable, and easily applicable to getting any JSON from any web API.

1 Answer

0 votes
by (10.3k points)

Hi Julien

It really depends on your data source. I wrote the JSON streaming parser library because all other existing parsers had problems to process big JSON responses. The JSON streaming parser is gentle on memory consumption but not very easy to use.

I think the ArduinoJSON library is relatively easy to use and if the JSON object you're trying to process is not too big it should work without problems: https://github.com/bblanchon/ArduinoJson It also works without problems on the ESP8266.

I am not aware of another JSON library for Arduino//ESP8266 that uses stream processing than my own JSON streaming parser. I explain how to use the parser in this blog post: https://blog.squix.org/2017/01/esp8266-the-json-streaming-parser.html

Please let me know if you found an easier and better way to consume JSON objects!

Daniel

by (120 points)
Hi, thanks for your quick answer!

Please, allow me to rephrase my question:

If I want to add a source to the weather station code,

via a proper, separate code (like WundergroundClient.cpp or TimeClient.cpp or WorldClockClient.cpp…)

Which one would be the best to start from?

I found WundergroundClient.cpp too complex to start from for exploring a simple json source (like for example https://api-ratp.pierre-grimaud.fr/v3/schedules/bus/26/ermitage/A+R ) and I suspect there's a lot of adhoc code in there (?).

As you said in the post "if this example is too simple…" (I had read it a couple weeks ago :-), and it is, but the wundergroundclient.cpp is IMHO too 'weird' / specific.

It would be great to have a good, correct* example, simple but complete, for getting and parsing a simple source and displaying it on the ESPaper using the Weatherstation code – and example in between the code in the post and the wundergroundclient.cpp

*correct in the sense of working well with the weatherstation code

Welcome to ThingPulse Q&A, where you can ask questions and receive answers from other members of the community.

https://thingpulse.com

...