Force char[] or const char * to be duplicated to JsonObject
Created by: ttlappalainen
JsonObject uses as default reference to values set by char[]. Is there way to force value to be duplicated? If I e.g. use JsonObject as reference getting class description: class MyClass : public BaseClass { ... virtual void GetJson(JsonObject &Json); };
and inside GetJson I have to generate some results: void GetJson(JsonObject &Json) { char Generated[100]; // do something to set content of Generated Json[strGeneratedKey]=Generated; };
I could not find good way to force value to be copied to buffer instead of referencing it, which does not work here. I can go around with Json[strGeneratedKey]=String(Generated);, which forces copy, but also makes extra work with String constructing etc. Also I do not want to carry JsonBuffer through a parameter list so that I could use strdup.
So is there some other way, which I did not see. And if not, would it be possible to add? Or does my basic idea to use JsonObject as reference paramter have some misunderstanding?