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

Having issues getting this runing with the the JSON 6 library. #17

Open
vangalvin opened this issue Jul 22, 2018 · 1 comment
Open

Having issues getting this runing with the the JSON 6 library. #17

vangalvin opened this issue Jul 22, 2018 · 1 comment

Comments

@vangalvin
Copy link

A quick look in to it and it appears that there is a compatibility issue with the new
version 6 JSON library.

@pippin88
Copy link

pippin88 commented Mar 10, 2019

spiffs_rest_api_nonblocking

Change:

    //build json object of program data
    StaticJsonBuffer<200> jsonBuffer;
    JsonObject &json = jsonBuffer.createObject();
    json["x"] = x;
    json["y"] = y;

    char jsonchar[200];
    json.printTo(jsonchar); //print to char array, takes more memory but sends in one piece
    server.send(200, "application/json", jsonchar);

To:

    //build json object of program data
    StaticJsonDocument<200> jsonBuffer;
    JsonObject json = jsonBuffer.to<JsonObject>();
    json["x"] = x;
    json["y"] = y;

    char jsonchar[200];
    serializeJson(jsonBuffer, jsonchar); //print to char array, takes more memory but sends in one piece
    server.send(200, "application/json", jsonchar);

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

2 participants