Reading a simple JSON data example


<script>

var result = [
  {
    "id": "11",
    "data": {
      "name": "anurag",
      "email": "anuragxxxxxx@gmail.com",
      "phone": "9990000000",
      "category": "Photography Requirements",
      "location": "noida sector 18",
      "requirement": "I need help. ",
      "website": "http:\/\/love.com",
      "projects": [
            "a","b","c"
      ]
    }
  },
  
  {
    "id": "12",
    "data": {
      "name": "anurag",
      "email": "anuragxxxxxx@gmail.com",
      "phone": "9990000000",
      "category": "Photography Requirements",
      "location": "noida sector 18",
      "requirement": "I need help. ",
      "website": "http:\/\/love.com",
      "projects": [
            "a","b","c"
      ]
    }
  }
]


var arr = result.length;

for(var i=0; i<arr; i++){

    document.write(result[i].id + '<br>');
    document.write(result[i].data.name + '<br>');
    document.write(result[i].data.email + '<br>');
    document.write(result[i].data.phone + '<br>');
    document.write(result[i].data.category + '<br>');
    document.write(result[i].data.location + '<br>');
    document.write(result[i].data.requirement + '<br>');
    document.write(result[i].data.website + '<br>');
    document.write(result[i].data.projects[0] + '<br>');
    document.write(result[i].data.projects[1] + '<br>');
    document.write(result[i].data.projects[2] + '<br><br><br>');
 }
            

</script>


Output:


Popular posts from this blog

What are sales territory in Netsuite?

How to get and set a sublist in netsuite suitlet suitescript 2.0