8000 How to use createNestedObject in a for loop? · Issue #87 · bblanchon/ArduinoJson · GitHub
[go: up one dir, main page]

Skip to content
How to use createNestedObject in a for loop? #87
@probonopd

Description

@probonopd

Sorry for bringing up one more question similar to #10, #57, #84 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      2 0