JSON Strings with quotes ...
Created by: Humancell
I'm slowly getting the hang of the library, and I'm parsing ok, but now I've hit an issue with comparing/checking values of the properties ... specifically Strings.
Using your example, if I have this JSON:
char json[] =
"{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
I can then successfully parse it.
Now, I want to check a value ... and this continues to fail:
Serial.print("sensor: ");
if (json.containsKey("sensor"))
{
json["sensor"].printTo(Serial); // NOTE: This prints "gps" with the quotes!
Serial.println();
if (json["sensor"]) == "gps") { // NOTE: Always fails! Unless changed to "\"gps\""
/*
* How can I compare/get the value WITHOUT the quotes?
* - I don't want to have to always put escaped quotes in all comparisons?
*/
}
How can I do a comparison of a string, but drop the quotes? Or reference the JSON string without the quotes?