dpkrai96 dpkrai96 - 5 months ago 9
jQuery Question

I have json object but I am unable to access 'name' element in this?

This is the json data



{"0":{"restaurant":"Bayleaf","order":"HIHUN10","delivery at":"04:43 PM 2016-06-22","type":"Home Delivery","name":"dEEPAK rAI","address":"12356,Lucknow,226010","phone":"9120276440","total":"Rs 831.60","pay by":"Cash On Delivery","picked by":"By Administrator","date":"06\/22\/2016","status":"Waiting","action":"pending"},"1":{"restaurant":"Jungliee","order":"HIHUN9","delivery at":"03:40 PM 2016-06-21","type":"Home Delivery","name":"dEEPAK rAI","address":"12356,Lucknow,226010","phone":"9120276440","total":"Rs 465.00","pay by":"Cash On Delivery","picked by":"Dummy","date":"06\/21\/2016","status":{"Accepted":1,"Processing":2,"Delivered":3,"Completed":4,"Failed":5},"action":"view"},"2":{"restaurant":"Naushijaan","order":"HIHUN8","delivery at":"11:10 AM 2016-06-18","type":"Home Delivery","name":"dEEPAK rAI","address":"12356,Lucknow,226010","phone":"9120276440","total":"Rs 545.00","pay by":"Cash On Delivery","picked by":"By Administrator","date":"06\/18\/2016","status":{"Processing":2,"Delivered":3,"Completed":4,"Failed":5},"action":"view"},"3":{"restaurant":"Aahaar","order":"HIHUN7","delivery at":"11:32 AM 2016-06-12","type":"Home Delivery","name":"sk mishra","address":"520viram khand,Lucknow,226010","phone":"9198979962","total":"Rs 450.00","pay by":"Cash On Delivery","picked by":"Dummy","date":"06\/12\/2016","status":{"Completed":4,"Failed":5},"action":"view"},"4":{"restaurant":"Bayleaf","order":"HIHUN6","delivery at":"08:29 PM 2016-06-11","type":"Home Delivery","name":"Dharmraj","address":"D-242Office G 19 Sector 63,Lucknow,201003","phone":"7428069025","total":"Rs 606.60","pay by":"Cash On Delivery","picked by":"By Administrator","date":"06\/11\/2016","status":{"Completed":4,"Failed":5},"action":"view"},"5":{"restaurant":"Bayleaf","order":"HIHUN5","delivery at":"08:17 PM 2016-06-11","type":"Home Delivery","name":"Dharmraj","address":"D-242Office G 19 Sector 63,Lucknow,201003","phone":"7428069025","total":"Rs 606.60","pay by":"Cash On Delivery","picked by":"By Administrator","date":"06\/11\/2016","status":{"Completed":4,"Failed":5},"action":"view"}}




Answer

var jsonData = {
  "0": {
    "restaurant": "Bayleaf",
    "order": "HIHUN10",
    "delivery at": "04:43 PM 2016-06-22",
    "type": "Home Delivery",
    "name": "dEEPAK rAI",
    "address": "12356,Lucknow,226010",
    "phone": "9120276440",
    "total": "Rs 831.60",
    "pay by": "Cash On Delivery",
    "picked by": "By Administrator",
    "date": "06\/22\/2016",
    "status": "Waiting",
    "action": "pending"
  },
  "1": {
    "restaurant": "Jungliee",
    "order": "HIHUN9",
    "delivery at": "03:40 PM 2016-06-21",
    "type": "Home Delivery",
    "name": "dEEPAK rAI",
    "address": "12356,Lucknow,226010",
    "phone": "9120276440",
    "total": "Rs 465.00",
    "pay by": "Cash On Delivery",
    "picked by": "Dummy",
    "date": "06\/21\/2016",
    "status": {
      "Accepted": 1,
      "Processing": 2,
      "Delivered": 3,
      "Completed": 4,
      "Failed": 5
    },
    "action": "view"
  },
  "2": {
    "restaurant": "Naushijaan",
    "order": "HIHUN8",
    "delivery at": "11:10 AM 2016-06-18",
    "type": "Home Delivery",
    "name": "dEEPAK rAI",
    "address": "12356,Lucknow,226010",
    "phone": "9120276440",
    "total": "Rs 545.00",
    "pay by": "Cash On Delivery",
    "picked by": "By Administrator",
    "date": "06\/18\/2016",
    "status": {
      "Processing": 2,
      "Delivered": 3,
      "Completed": 4,
      "Failed": 5
    },
    "action": "view"
  },
  "3": {
    "restaurant": "Aahaar",
    "order": "HIHUN7",
    "delivery at": "11:32 AM 2016-06-12",
    "type": "Home Delivery",
    "name": "sk mishra",
    "address": "520viram khand,Lucknow,226010",
    "phone": "9198979962",
    "total": "Rs 450.00",
    "pay by": "Cash On Delivery",
    "picked by": "Dummy",
    "date": "06\/12\/2016",
    "status": {
      "Completed": 4,
      "Failed": 5
    },
    "action": "view"
  },
  "4": {
    "restaurant": "Bayleaf",
    "order": "HIHUN6",
    "delivery at": "08:29 PM 2016-06-11",
    "type": "Home Delivery",
    "name": "Dharmraj",
    "address": "D-242Office G 19 Sector 63,Lucknow,201003",
    "phone": "7428069025",
    "total": "Rs 606.60",
    "pay by": "Cash On Delivery",
    "picked by": "By Administrator",
    "date": "06\/11\/2016",
    "status": {
      "Completed": 4,
      "Failed": 5
    },
    "action": "view"
  },
  "5": {
    "restaurant": "Bayleaf",
    "order": "HIHUN5",
    "delivery at": "08:17 PM 2016-06-11",
    "type": "Home Delivery",
    "name": "Dharmraj",
    "address": "D-242Office G 19 Sector 63,Lucknow,201003",
    "phone": "7428069025",
    "total": "Rs 606.60",
    "pay by": "Cash On Delivery",
    "picked by": "By Administrator",
    "date": "06\/11\/2016",
    "status": {
      "Completed": 4,
      "Failed": 5
    },
    "action": "view"
  }
};
$.each(jsonData, function(index, value) {
  console.log(JSON.stringify(value.name));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Comments