0

EMULATOR "fr945"

MIN API LEVEL "3.0.0"

API DATA STRUCTURE

{         
  "data": {
    "devices": [           
        {
            "device": "00:0E:00:AD:00:00:00:4A",
            "model": "H6008",
            "deviceName": "Mudroom",
            "controllable": true,
            "retrievable": true,
            "supportCmds": [
                "turn",
                "brightness",
                "color",
                "colorTem"
            ],
            "properties": {
                "colorTem": {
                    "range": {
                        "min": 2700,
                        "max": 6500
                    }
                }
            }
        }
      ]
    },
    "message": "Success",
    "code": 200
}

CODE

 if (args instanceof Dictionary) {

        var keys = args.keys();
        _message = "";
        for (var i = 0; i < keys.size(); i++) {
            _message += Lang.format("$1$: $2$\n", [keys[i], args[keys[i]]]);
        }
    }

When I run through the object, message and code print(and their values), but data does not. Even so, getting it to print wouldn't solve my issue, I am trying to drill into the data.devices[] array to be able to access the information in each array index. Ex: data.devices[0].dataName and print that information.

Is this even possible with Monkey C?

1 Answers1

0

Roughly figured it out-

       var devices = data["data"]["devices"];            
        var devicesSize = devices.size();


        for (var i = 0; i < devicesSize; i++) {
            var device = devices[i];
               Sys.println(device);
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 08 '23 at 04:35