Reading parsed numbers fails on esp8266
Created by: JeffAshton
Adding debugging messages to the provided the parsing example:
// Copyright Benoit Blanchon 2014-2015
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
#include <ArduinoJson.h>
void setup() {
Serial.begin(115200);
StaticJsonBuffer<200> jsonBuffer;
char json[] =
"{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
JsonObject& root = jsonBuffer.parseObject(json);
if (!root.success()) {
Serial.println("parseObject() failed");
return;
}
Serial.println("reading: sensor");
const char* sensor = root["sensor"];
Serial.println("reading: time");
long time = root["time"];
Serial.println("reading: latitude");
double latitude = root["data"][0];
Serial.println("reading: longitude");
double longitude = root["data"][1];
Serial.println(sensor);
Serial.println(time);
Serial.println(latitude, 6);
Serial.println(longitude, 6);
}
void loop() {
// not used in this example
}
produces the following:
reading: sensor
reading: time
Exception (29):
epc1=0x40204377 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
ctx: cont
sp: 3ffe9b50 end: 3ffe9e80 offset: 01a0
>>>stack>>>
3ffe9cf0: 3ffe8841 00000000 3ffe8d70 3ffe9eac
3ffe9d00: 3ffe9df7 3ffe9d24 3ffe9e00 40202760
3ffe9d10: 3ffe8d70 3ffe9d24 3ffe8d70 4020219c
3ffe9d20: 3ffe88c0 3ffe9d20 3ffe9d2c 3ffe9d4c
3ffe9d30: 00000000 3ffe9df0 00000000 00000002
3ffe9d40: 3ffe9eac 3ffe9df7 3ffe8e60 3ffe9da4
3ffe9d50: 00000000 3ffe9dfb 00000000 00000001
3ffe9d60: 3ffe9eac 3ffe9e00 3ffe8e60 3ffe9d20
3ffe9d70: 3ffe9d74 3ffe9d8c 00000000 00000001
3ffe9d80: 00000000 3ffe9e10 00000000 00000000
3ffe9d90: 00000000 00000001 00000000 3ffe9e1a
3ffe9da0: 00000000 00000000 00000000 3ffe9e0b
3ffe9db0: 00000000 00000005 3ffe9eac 3ffe9d6c
3ffe9dc0: 3ffe8e60 00000000 00000000 00000000
3ffe9dd0: 00000000 00000000 00000000 00000000
3ffe9de0: 00000000 00000000 00000000 000000a0
3ffe9df0: 736e6573 6700726f 74007370 00656d69
3ffe9e00: 31353331 31343238 64003032 00617461
3ffe9e10: 372e3834 38303635 2e320030 30323033
3ffe9e20: 2c003833 30332e32 38333032 00007d5d
3ffe9e30: 00000000 00000000 00000000 00000000
3ffe9e40: 00000000 00000000 00000000 00000000
3ffe9e50: 00000000 00000000 00000000 3ffe9eac
3ffe9e60: 3fffdc20 00000000 3ffe9ea4 40201e2b
3ffe9e70: 00000000 00000000 3ffe8e60 40100378
<<<stack<<<