Hi,
I want to deal within my Photon project with JSON file. The idea is that Photon can receive string of JSON, and then retrive the different value in that file. For example I send:
{"type": "myType","value": "theValue"}
Then I want within my software to retrive with a solution similar to this one:
String type = JSON.PARSER["type"];
String value = JSON.PARSER["value"];
@zebrone92, Iâm using that lib presently for both encoding and decoding JSON. It works quite well and the author is actively supporting it. Note that the version on the IDE (I suspect 4.x) is not the latest (5.1).
A quick update for those using this library with the standalone Particle IDE and using the source from GIT.
If you get the error: âSparkJson.h: No such file or directoryâ, this is because the Particle IDE expects libraries to be in this structure:
MyProject
lib
SparkJson
src
src
By renaming the SparkJson subfolder âfirmwareâ folder to âsrcâ, youâll get rid of this error.
If you get the error âJsonServer.ino:6:22: fatal error: Ethernet.h: No such file or directoryâ itâs because the Particle IDE dislikes the âexamplesâ folder inside the âsrcâ folder (the one you renamed from âfirmwareâ above). Just move the Examples folder out of the âsrcâ folder to solve this.
For some reason, the author has an .ino file in the middle of the source code? This causes the Particle IDE to complain with an error like this:
In function `setupâ: lib/SparkJson/src/my-core.ino:9: multiple definition of âsetupâ
Just delete the file âmy-core.inoâ from your source folder and your project should compile.
Note: the memory footprint for this library is surprisingly large at 15 820 bytes (using 200 char static buffer). The ArduinoJson library is only 8 588 bytes (using same buffer size) and seems better maintained.
JsonParserGeneratorRK4 looks like the better option, so Iâll go for that! Gotta say that @rickkas7 have saved me a couple times now. Iâve gotta buy him some beers when I meet him!
(Sorry for reviving an old thread, but it comes up first in search so I figured that I could just as well keep it updated)