Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.2 can't parse the jsonObject in jsonArray #53

Closed
yuanhaoliang opened this issue Mar 2, 2015 · 1 comment
Closed

4.2 can't parse the jsonObject in jsonArray #53

yuanhaoliang opened this issue Mar 2, 2015 · 1 comment
Labels
v5 ArduinoJson 5

Comments

@yuanhaoliang
Copy link

#include <ArduinoJson.h>

void setup() {
  Serial.begin(9600);
  delay(2000);
  StaticJsonBuffer<200> jsonBuffer;

  char json[] =
      "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[{\"a\":48.756080,\"b\":2.302038}]}";

  JsonObject& root = jsonBuffer.parseObject(json);

  if (!root.success()) {
    Serial.println("parseObject() failed");
    return;
  }

  const char* sensor = root["sensor"];
  long time = root["time"];
  JsonArray& array = root["data"];


  Serial.println(sensor);
  Serial.println(time);
  Serial.println(array.size());
}

void loop() {
  // not used in this example
}

array.size() is 0.
It seems parse fail,but no error occur.

@yuanhaoliang
Copy link
Author

maybe the size 200 for StaticJsonBuffer is too small. The size up to 2000 is OK!

Repository owner locked and limited conversation to collaborators Sep 21, 2018
@bblanchon bblanchon added the v5 ArduinoJson 5 label Feb 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
v5 ArduinoJson 5
Projects
None yet
Development

No branches or pull requests

2 participants