[APP][Pro] JSON Handler and Manipulator

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.


→
image



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

image

The bottom card will execute the above (Trigger/When) card three times.
Result:
image

Here is another example:



Please report issues or feature requests at QlusterIT / nl.qluster-it.JsonHandler/ issues — Bitbucket.


Apps:

Donations or Sponsorship

2 Likes

Reserved

Reserved 2

Reserved 3

Why not use the built in cards. Abusing arguments like this make things very ugly.

Because that means many cards.
This way flows can have way less cards when interacting with e.g. HomeyScript!

Also, when using Read JSON, you will get all the same TAG’s.
With JSON Handler Retrieve cards, you get different Tagnames; which makes it more readable i.m.h.o.

And, as you perhaps have noticed allready, people allready are using different methods instead of the default JSON editors, because it creates to many cards: HomeyScript: Any sane ways to use args? - Questions & Help - Homey Community Forum

I’m not sure how that is related to this? You would still need to do JSON.parse(args[0]) in your script. Since Homey does not really have a JSON type token.

Yes, ofc, indeed you need to parse the json in HS.

But with this app you don’t need to manually parse it (and remember the double quotes for strings) like this:

Also you dont need to customly define the JSON and than add all properties through multiple cards like this:

Now you just need:

Will give it a shot in the future. At this moment i am rewriting all my flows into the advanced flows. I also have many flows involving json. They were a hell of a job, so maybe this is THE app for me. In advance thx for creating this. I hope that my old method with this app is easier, had to make 24 calls collecting data about themperature, humidity, wind, etc etc for every hour. For three collections of data that will be 72 calls. And i have many many other data that i wanted to collect. Just a little example how it now worked

1 Like

Version 1.0.4 is live in store now: JSON Handler App voor Homey | Homey

Say you are using the Read JSON card with 3 arguments.
Can you use only 2 of the arguments?
Can you use both argument-text1 and argument-number1, or only one of them?

Any way you wanna go.
Almost all arguments are optional, so you could, if you wish, always use the 3x10 argument card, also if you just start with one text.

The json is also optional: if non is supplied, a json object is created.

Also, properties that are non existing on existing Json’s, are created when filled. So, no need to pre-define the Json structure.

Hi,

I hoping this app are what I need but I don’t know if it’s possible and I have a hard time to get started.

I’m using the Asus WRT app connected to my router and from that I get a trigger when some device connects to the router. From the trigger card there are four tags, name, nickname, IP and MAC.

What I like to do is to have a database that updates dynamic with connected devices. Is it possible with this app? Any tip to get me started?

Thanks

I think you’ll need a little MySQL server and this app [APP][PRO] MySQL-Client

Would it be possible to have the tag names set dynamically?
When using the tags in a flow the name “Text1” is better than “result” but still making it cumbersum to remember which tag holds what value.

Hey,

Well i see two possible options:

  • Create Global Tags on the fly.
    A flowcard would not have Set Text1 = [input], but more something like Set [name]=[input], where you could fill in the name and a Global Tag would be created.
  • A Virtual/Fake Device with customisable property names ( like AVD), which you could set through flowcards like the current JSON cards.

But both solutions have one very big weakness: Using the same tag at the same time is gonna create issues, because the scope of the Results are outside of the Flow.
This can/will cause “random” feeling errors.

This makes any solutions that i currently can see, not very usefull.

Ok, that doesn’t sound as any good solutions.

When i am done with AVD and The Flow Exchange(r) - Exchange Your Flows with Others! - Apps - Homey Community Forum i might take another look at the possibilities. But thats all i can promise.

1 Like

So the Homey code requires the tags from an action card must have static result tag(s)?!
This is why you have different sizes of JSON handler cards.
I hope this will be changed in upcomming Homey releases.