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

How to modify Json #7

Open
Robokishan opened this issue Feb 15, 2019 · 0 comments
Open

How to modify Json #7

Robokishan opened this issue Feb 15, 2019 · 0 comments

Comments

@Robokishan
Copy link

    char QC_JSON[1024] = <normalJson>;
    DynamicJsonBuffer jsonBuffer;
    JsonObject& root = jsonBuffer.parseObject(QC_JSON);
    if(root.success())
    {
      Serial.print("QC:");Serial.println(sizeof(QC_JSON));
      int lab = root["lab"];
      Serial.print("Json:");Serial.println(lab);
      memset(QC_JSON, 0, sizeof(QC_JSON));
      root.prettyPrintTo(Serial); 
      root.add("lab",int(3));      
      root.printTo(QC_JSON,sizeof(QC_JSON));
      String buffer = String(QC_JSON);
      Serial.println(buffer);
    }

now at this line

memset(QC_JSON, 0, sizeof(QC_JSON));
root.prettyPrintTo(Serial); 

output

{
  "": 2,
  "": "",
  "": "",
  "": ""
}

all the key values are gone why is this happening ?? Is root object address point to char buffer ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant