Tuesday, 15 August 2017

Nested JSON Object With Example - W3tricks

Nested JSON Object





  • JSON is also allowed to Nested JSON object.
  • Nested JSON object is same as multiple array object. 
  • Simple syntax start with ' { ' and end ' } ' Symbol Like main JSON.

Syntax

  • var student = {
    • "student1" : {
      • "name" : "Bob",
      • "age" : "18",
      • "city" : "new york"
    • },
    • "student2" : {
      • "name" : "Alice",
      • "age" : "16",
      • "city" : "paris"
    • }
  • };

Output

How to call Single Object In Nested JSON Object?

Syntax

  • console.log(student.student1);

Output

How to call Single Value In Nested JSON Object?

Syntax

  • console.log(student.student1.name);

Output


0 comments:

Post a Comment