Hi Guys,
I started to use your library, I like is a lot because of it's simplicity and lightness.
I've encountered an issue though, when I need to deserialize a json and retrieve a bool value it seems not to work.
Example json:
{"_id":"637a8b27171c8e5a9","name":"somename","type":"a4","apikey":"someapikey","deviceid":"a48003cb","createdAt":"2022-11-20T20:16:35.783Z","online":true}
example code:
void setup() {
Serial.begin(115200);
String test_json = "{"_id":"637a8b27171c8e5a9","name":"somename","type":"a4","apikey":"someapikey","deviceid":"a48003cb","createdAt":"2022-11-20T20:16:35.783Z","online":true}";
delay(5000);
Serial.println(jsonExtract(test_json, "name")); // result is somename which is good :)
Serial.println(jsonExtract(test_json, "online"));
}
// result is {"_id":"637a8b27171c8e5a9","name":"somename","type":"a4","apikey":"someapikey","deviceid":"a48003cb","createdAt":"2022-11-20T20:16:35.783Z","online":
I was in a hurry so what I did to resolve it is added a few lines to jsonlib.cpp from line 120:
// bool
else if(json.substring(start, start + 4) == "true"){
stop = start + 4;
}
else if (json.substring(start, start + 5) == "false"){
stop = start + 5;
}
This way it interprets bool now.
Please let me know if there is an another way to do that.
Thanks in advance,
Kornel
Hi Guys,
I started to use your library, I like is a lot because of it's simplicity and lightness.
I've encountered an issue though, when I need to deserialize a json and retrieve a bool value it seems not to work.
Example json:
{"_id":"637a8b27171c8e5a9","name":"somename","type":"a4","apikey":"someapikey","deviceid":"a48003cb","createdAt":"2022-11-20T20:16:35.783Z","online":true}
example code:
void setup() {
Serial.begin(115200);
String test_json = "{"_id":"637a8b27171c8e5a9","name":"somename","type":"a4","apikey":"someapikey","deviceid":"a48003cb","createdAt":"2022-11-20T20:16:35.783Z","online":true}";
delay(5000);
Serial.println(jsonExtract(test_json, "name")); // result is somename which is good :)
Serial.println(jsonExtract(test_json, "online"));
}
// result is {"_id":"637a8b27171c8e5a9","name":"somename","type":"a4","apikey":"someapikey","deviceid":"a48003cb","createdAt":"2022-11-20T20:16:35.783Z","online":
I was in a hurry so what I did to resolve it is added a few lines to jsonlib.cpp from line 120:
// bool
else if(json.substring(start, start + 4) == "true"){
stop = start + 4;
}
else if (json.substring(start, start + 5) == "false"){
stop = start + 5;
}
This way it interprets bool now.
Please let me know if there is an another way to do that.
Thanks in advance,
Kornel