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.