4 Replies Latest reply on Dec 8, 2015 9:23 AM by bsmith RSS
    bsmith Apprentice

    How to read in a complex json for mashups?

    Can someone give me pointer to the documentation, examples, and preferred methods on how to input complex json from an external source.

     

    Note: We are not allowed to reach into the provider for the JSON so ContentLoader functions are not an option, the provider will have to push it to the ThingWorx platform.

     

    That being the case, I tried using RESTFul API with POST with JSON payload and invoking a service with that JSON as the input and then parsing through the JSON.

     

    Having little success (but great frustration) in getting the JSON input into the service.

     

    References on the Developer Community (Pai Chung Jul 20, 2015 "How to Convert JSON received from REST API to Bind to Object or Variable") suggests: “If you input parameter is defined as JSON or if you are using a Service that retrieves JSON, ThingWorx will treat it as an Object.  So {MyValue:123} can be retrieved as JSONObjectVariable.MyValue”

     

    I defined the input as JSON however, this does not work (or I can’t get it to work) and some guidance would be greatly appreciated.

     

     

    I have seen several threads which discuss in and around the subject in various degrees.

     

    For example, I need to input the following json and act upon it (i.e display mashups)

     

    {
        "server": {
            "disk": {
                "used": "1240M",                        
                "capacity": "1416M"                    
            },
            "ethernet": {
                "address": "192.168.x.xxx",
                "mac": "00:xx:yy:zz:ww:99"             
            },                                           
            "cpu": {
                "average": "0.04",                     
                "uptime": "19 days, 11:16",            
                "load": "0.24",                        
                "temp": "76.8"                         
            },
            "location": "Unknown",                     
            "name": "MyLinux",
            "version": "6.5",                        
    }
    }

     

    Thanks,