-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a char as a member of a JsonDocument produces a convertToJson error #2043
Comments
Hi @smaslincosi, ArduinoJson 6.18 deprecated the support for "naked" JSON supports numbers and strings but has no "character" type. If you cannot live without namespace ArduinoJson {
template <>
struct Converter<char> {
static void toJson(char c, JsonVariant var) {
char buf[] = {c, 0};
var.set(buf);
}
static char fromJson(JsonVariantConst src) {
auto p = src.as<const char*>();
return p ? p[0] : 0;
}
};
} Best regards, |
Thank you for the incredibly helpful information! |
You're welcome, @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 aStaticJsonDocument
without issue. In v7 adding achar
to aJsonDocument
produces an error with theconvertToJson
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
convertToJson(...)
"Environment
Reproduction code
The text was updated successfully, but these errors were encountered: