Announcement

Collapse
No announcement yet.

Easiest way to parse external JSON data?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Easiest way to parse external JSON data?

    I have a device in my LAN that I'd like to monitor. It provides JSON data.


    I tried to access it directly with HSTouch, but it seems the RSS function can't handle JSON format.


    Is there a simple way (built-in or plug-in) to retrieve JSON from an URL, and save the data into virtual devices?


    Or if the only way is by custom script... is there a sample I could use as starting point?


    Much thanks!

    #2
    HS uses the NewtonSoft JSON library so you may be able to leverage it with some script to help. mcsMQTT plugin parses incoming JSON from MQTT messages. In this case I did a custom parse based upon the nature of the data that was coming from my external sources.

    Comment


      #3
      You can also add this line to your ScriptingReferences line and use the .net inbuilt JSON parsing methods - System.Web.Extensions;System.Web.Extensions.dll

      The way to do it seems to be to deserialise the JSON data into a .net class, depending on the complexity of your JSON data depends on how easy this is - for anything complex you can use tools like http://jsonutils.com/ which enables you to generate VB.net class syntax for a given set of data.

      When it comes to getting the data out you wish for you then send the call to the JavaScriptSerializer and then ask it to convert your string of data to the class you have built - it is then done behind the scenes then you access the bits you want. I think I have posted examples before so if you search for the above DLL file you might find something somewhere as a starting point.

      Comment


        #4
        Big5 plug-in handles REST API and JSON easily.

        Comment

        Working...
        X