Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A ArduinoJson
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 24
    • Issues 24
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Benoît Blanchon
  • ArduinoJson
  • Issues
  • #1730
Closed
Open
Issue created Mar 18, 2022 by Administrator@rootContributor

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
  1. The issue happens at compile time
  2. 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.

Assignee
Assign to
Time tracking