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
  • #87
Closed
Open
Issue created Jul 09, 2015 by Administrator@rootContributor

How to use createNestedObject in a for loop?

Created by: probonopd

Sorry for bringing up one more question similar to #10 (closed), #57 (closed), #84 (closed) but this appears to be strange for beginners.

I am trying to generate

{  
   "lights":{  
      "1":{  
         "name":"Lamp 1"
      },
      "2":{  
         "name":"Lamp 2"
      },
...
      "999":{  
         "name":"Lamp 999"
      }
   }
}

using a function addLight(root, i) that I need to call for a dynamic number i of lights which is determined at runtime (in the above example, i is 1...999). Looking at https://arduinojson.org/doc/pitfalls/#6-do-not-assume-that-strings-are-copied I am pretty certain that what I am doing right now is entirely wrong (and the result is a crash) but I cannot quite figure out what I need to do instead.

Assignee
Assign to
Time tracking