Can't extract from nested JSON
Created by: nicksterious
Describe the bug
I am getting a compile error when trying to extract a portion of a nested JSON document.
Troubleshooter report
Here is the report generated by the ArduinoJson Troubleshooter:
ArduinoJson Troubleshooter's report
- The issue happens at compile time
- The error is not in the list
Environment
Here is the environment that I used:
- Microcontroller: RP2040
- Core/runtime: arduino mbed
- IDE: VSCode/platformio
Reproduction
Here is a small snippet that reproduces the issue.
{
"state": {
"desired": {
"welcome": "aws-iot",
"powerState": "OFF"
},
"reported": {
"welcome": "aws-iot",
"powerState": "OFF"
}
},
"metadata": {
"desired": {
"welcome": {
"timestamp": 1647421659
},
"powerState": {
"timestamp": 1647594171
}
},
"reported": {
"welcome": {
"timestamp": 1647421659
},
"powerState": {
"timestamp": 1647594576
}
}
},
"version": 531,
"timestamp": 1647620956
}
DynamicJsonDocument incoming_message(2048);
DynamicJsonDocument thing_state(2048);
deserializeJson(incoming_message, incoming_message_str);
thing_state = incoming_message["state"];
// at this point thing_state should contain the "state" but not the "metadata"
Compiler output
.pio\libdeps\pico\ArduinoJson\src/ArduinoJson/Document/BasicJsonDocument.hpp:100:31: error: 'const class ArduinoJson6193_F1::MemberProxy<ArduinoJson6193_F1::JsonDocument&, const char*>' has no member named 'memoryUsage'
100 | size_t requiredSize = src.memoryUsage();
| ~~~~^~~~~~~~~~~
*** [.pio\build\pico\src\main.cpp.o] Error 1
Expected output: Program should compile and maybe work.