Live in Store now!
Lightweight app for creating, manipulating and retrieving JSON objects.
You can alter a existing JSON object, or one will be created.
No need to pre-define the structure.
You can, for example, use the output JSON token as HomeyScript argument, and use JSON.parse(args[0]) to read the object you created.
Creating and Manipulating JSON.
Output from the bottom left two cards:
{
"main5": true, // or "main10": true,
"1arg": {
"test1": true,
"light": {
"text": "Test1"
},
"Intend": 8,
"Bool": true
},
"3args": {
"test3": true,
"light": {
"text": "Test3"
},
"Intend": 8,
"Bool": true
},
"5args": {
"test5": true,
"light": {
"text": "Test5"
},
"Intend": 8,
"Bool": true
},
"10args": {
"test10": true,
"light": {
"text": "Test10"
},
"Intend": 8,
"Bool": true
}
}
Reading JSON.
Reading the above generated JSON.
→
Loop cards
Essentially, i created a loop
card, or for each
for (var (item,key,index) in Collection) {
}
It works pretty easy, you need two cards:
- A When/Trigger Card, which will be triggered for each item in the collection, with these tokens:
- Item as Text
- Item as Number
- Item as Yes/No
- Key
- Index
- Text 1 (argument)
- And a Then/Action Card, which you supply with an (json) collection (array or obj) and an optional argument.
The When card will be execute for each item in the collection, with the supplied tokens.
Example
The bottom card will execute the above (Trigger/When) card three times.
Result:
Here is another example: