To pull the object names out of a JSON object, iterate through the JSON object and display the value at each index location

  • Example:
    var myJson = {
    "element1": "hello",
    "element2": 12,
    "element3": true,
    "element4": {
        "subelement1": "one",
        "sebelement2": 2
    }};
     
    for (var el in myJson) {
        console.log("Element name: " + el + ", element value:" + myJson[el] + ", element type: " + typeof(myJson[el]));
    }

JSON array
  • Example:
    var propertiesPort = ['port1', 'port2', 'port3', 'port4', 'port5', 'port6', 'port7', 'port8', 'port9', 'port10', 'port11', 'port12' ];
    for(var i = 0; i<propertiesPort .length; i++){

                    var portName = propertiesPort [i];

    }

    hoặc:

    for
     each (row in thingList.rows) { 
        //Now each row is already assigned to the row variable in the loop
        var thingName = row.name;