Skip to content

Adding a char as a member of a JsonDocument produces a convertToJson error #2043

Closed
@smaslincosi

Description

@smaslincosi

Description
I am in the process of migrating existing code to ArduinoJson v7, and I have had issues with compilation that I believe stem from changes to the library. In previous versions of the library, I was able to add a char to a StaticJsonDocument without issue. In v7 adding a char to a JsonDocument produces an error with the convertToJson function.
My intended target is Teensy 3.2, but I have been able to reproduce this issue with the provided code on other platforms such as Arduino Uno.
My provided reproduction code works with version 6.19.4, but not with 6.20.0 or thereafter.

Troubleshooter's report

  1. The program uses ArduinoJson 7
  2. The issue happens at compile time
  3. Error says "no matching function for call to ..."
  4. Error says "no matching function for call to convertToJson(...)"
  5. Converting the value doesn't fix the issue

Environment

  • Microcontroller: Teensy 3.2
  • Core/Framework: Teensyduino
  • IDE: Arduino IDE 2.2.1

Reproduction code

#include <ArduinoJson.h>

void setup() {

  JsonDocument doc;

  //This will compile:
  //const char* cs = "A";
  //doc["val"] = cs;

  //This will not compile with ArduinoJson version 6.20.0 or greater - error: no matching function for call to 'convertToJson(const char&, ArduinoJson::V702L1::JsonVariant&)'
  char c = 'A';
  doc["val"] = c;
}

void loop() {
  // put your main code here, to run repeatedly:

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionv6ArduinoJson 6v7ArduinoJson 7

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions