Skip to content

POST() with a JsonVariant response never parses the returned JSON #71

Description

@davidchatting-bot

Where

`YoYoWiFiManager::POST(const char *server, const char *path, JsonVariant payload, char *response)` in `src/YoYoWiFiManager.cpp`:
```cpp
int YoYoWiFiManager::POST(const char *server, const char *path, JsonVariant payload, char *response) {
int httpResponseCode = -1;

String jsonAsString;
jsonAsString.reserve(payload.memoryUsage());
if(serializeJson(payload, jsonAsString) > 0) {
httpResponseCode = POST(server, path, jsonAsString.c_str(), "application/json", response);
if(response) {
//TODO: parse json
}
}

return(httpResponseCode);
}
```

Problem

When a caller passes a non-null `response` buffer, the inner `POST(..., char *response)` call already fills it with the raw response body (see #68 re: that copy being unbounded), but the `if(response) { //TODO: parse json }` block here does nothing with it - so this overload's whole reason for existing (JSON in, presumably JSON-parsed-out) isn't actually implemented, despite already having the raw string in hand.

Ask

Either parse `response` into a `JsonDocument` here (there's already a `GET(server, path, JsonDocument&)` overload nearby to use as a model), or change this overload's `response` parameter to a `JsonDocument&` to match, rather than a raw `char *` that never gets interpreted as JSON.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions