Tuesday, 15 August 2017

How to Multiple Array Object In JSON Data With Example - W3tricks

Multiple Array Object In JSON Data




  • JSON is also allowed to multiple array object. 
  • In Array object is sub JSON inside to the main JSON. 
  • Simple syntax start with ' { ' and end ' } ' Symbol Like main JSON.

Simple Multiple Array Object In JSON Data

  • var student = { "id" : "1", "name" : "Bob", "class" : [{ "Sub1" : "English", "Sub" : "French" }, { "Sub1" : "English", "Sub" : "French" }]};
  • console.log(student);

Output

How to Call Single Value In JSON Multiple Array Object ?

  • var student = { "id" : "1", "name" : "Bob", "class" : [{ "Sub1" : "English", "Sub" : "French" }, { "Sub1" : "English", "Sub" : "French" }]};
  • console.log(student.class[0]);

Output

How to Call Single Value In JSON Multiple Array Value ?

  • var student = { "id" : "1", "name" : "Bob", "class" : [{ "Sub1" : "English", "Sub" : "French" }, { "Sub1" : "English", "Sub" : "French" }]};
  • console.log(student.class[0].Sub1);

Output

Nested Multiple Array Object In JSON Data

  • var student = [{"Id" : "1", "Name" : "Bob", "Class" : [ { "Sub1" : "English" , "Sub" : "French" }]}, { "Id" : "2", "Name" : "Alice", "Class" : [{ "Sub1" : "English", "Sub" : "French" }]}];
  • console.log(student);

Output


0 comments:

Post a Comment