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
  • #1860
Closed
Open
Issue created Jan 18, 2023 by Administrator@rootContributor

Issue with JsonVariant.as<T>() where T is char * Need to update docs!

Created by: djaus2

Describe the bug
When using the example to iterate thjrough elements of a Json Document ins the part .as<T>() can't use char* for T

Troubleshooter report
Here is the report generated by the ArduinoJson Troubleshooter:

  1. The issue happens at compile time
  2. Error says "no matching function for call to ...(<unresolved overloaded function type>)"
  3. Adding the parentheses doesn't fix the issue .. Weren't missing in the parenthesis first place.

PS Liked that trouble shooter.

Environment
Here is the environment that I used:

  • Microcontroller: RP2040
  • RPI Pico W
  • IDE: Arduino IDE 1.2.03

Reproduction
This is a compile time error only. Small sketch with same code as per documentation:

  DynamicJsonDocument doc(1024);
  deserializeJson(doc, "{\"first\":\"\",\"second\":\"second\"}");
  JsonObject root = doc.as<JsonObject>();

  // using C++11 syntax (preferred):
  for (JsonPair kv : root) {
      Serial.println(kv.key().c_str());
      Serial.println(kv.value().as<char *>());
  }

Workaround: replace char * with String

Further: I see its deprecated anyway const char* as<char*>() const; // ⚠️ deprecated since 6.18 const char* as<const char*>() const;

SO DOCUMENTATION NEEDS UPDATE.. I spent hours on this! But thanks anyway for the library.

Compiler output
Compilation error: no matching function for call to 'ArduinoJson6200_F1::JsonVariant::as<char*>()'

Assignee
Assign to
Time tracking