Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


How to decode Json / Lua in Variable


hoschi_66

Recommended Posts

Hello, i have a question.

how can i write result from a JSON in a Fibaro Variables

 

This code works but i don't Know how i can write into Variables 

can anybody help many thanks

 

Please login or register to see this code.

 

 

and here the resalt

 

[DEBUG] 17:21:36: ["80s 90s stuff","miro","SIA","Top Hits Deutschland"]
 

 

 

Link to comment
Share on other sites

you have two command for working with json on HC2:

json.decode()

json.encode()

 

in your example

Please login or register to see this code.

the result for 'b[1]' is:
80s 90s stuff

b[2] is:

miro

...

 

 

 

 

 

Link to comment
Share on other sites

  • Topic Author
  • Hi Thank,

    but in your post  "a" is a fix variable.. how can i  write my "Call" into "a"

     

    thanks

     

    Markus 

    Link to comment
    Share on other sites

  • Topic Author
  • Please login or register to see this code.

    well i  check this but now i have another Problem..

     

    in the JSON file the field "integrations" sometimes not exist so the lua Code went into an ERROR... how can i handle this

     

     

     

    can you please help

     

    Edited by hoschi_66
    Link to comment
    Share on other sites

    Please login or register to see this code.

     

    Hope it helps

    Enjoy coding :-)

    Link to comment
    Share on other sites

  • Topic Author
  • On 3/2/2020 at 9:46 PM, Sankotronic said:

    Please login or register to see this code.

     

    Hope it helps

    Enjoy coding :-)

     

     

    nice many thanks  it works !!! and it is so easy :-) sometimes in Germany we Say " man sieht den Wald vor lauter Bäume nicht !"  now i can testing with Owntracks :-)

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...