-
-
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
Problem with StaticJsonDocument.as<JsonVariant>() when forwarding a template argument as capacity #977
Comments
Hi Yan, This is one of the dark corners of C++: when you call a template method inside a template method, you must use BTW, in the case studies of Mastering ArduinoJson, I demonstrate how to create a memory-efficient JSON-RPC library. Regards, |
Thanks Benoît, that works! Sometimes, compiler warnings are really misleading and incomprehensible... I read your book Mastering ArduinoJson 6 with pleasure and learned a lot. I also saw your memory-efficient I wonder, is it possible to rename a key in a Update: I probably should open another issue for this, right? |
Thank you very much for purchasing the book. Renaming a key used to be possible in ArduinoJson 5 but is currently not supported in version 6. Please open a new issue and explain the use case, so I can understand why you need that and find the most appropriate syntax. |
Done! #979 |
Hi Benoît,
I am writing a Json-RPC library based on ArduinoJson and cannot figure out a compilation error I keep getting.
My goal is to have a classmethod as template that takes one argument, namely the capacity of a
StaticJsonDocument
in the method. When I hard-code the capacity (bad design), everything works. If I use the template argument as capacity, I geterror: expected primary expression...
at a strange place: when I isedoc.as<JsonVariant>()
. (The library usesJsonVariant
s due to its flexibility).Wandox Minimal Example
https://wandbox.org/permlink/S4u8O3SSMSbzmJZK
Output:
Source code line in library
I neither understand this error nor do I know how to look for solutions :-S I know I could use a
DynamicJsonDocument
but following the advice in your book I try to avoid the heap as much as possible :-)Any help would be much appreciated.
Yann
The text was updated successfully, but these errors were encountered: