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
  • #658
Closed
Open
Issue created Jan 06, 2018 by Administrator@rootContributor

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?

Assignee
Assign to
Time tracking