26.3. JSONΒΆ

  1. Which of the following three code snippets is correct JSON syntax? Why are the other two options incorrect?

    1. {
         type: "dog",
         name: "Bernie",
         age: 3
      }
      
    2. {
         "type": "dog",
         "name": "Bernie",
         "age": 3
      }
      
    3. {
         "type": 'dog',
         "name": 'Bernie',
         "age": 3
      }
      

    Check your solution.

  2. Which of the following three code snippets is correct JSON? Why are the other two options incorrect?

    1. {
         "animals": [
            {
                  "type": "dog",
                  "name": "Bernie",
                  "age": 3
            },
            {
                  "type": "cat",
                  "name": "Draco",
                  "age": 2
            }
         ]
      }
      
    2. {
         [
            {
                  "type": "dog",
                  "name": "Bernie",
                  "age": 3
            },
            {
                  "type": "cat",
                  "name": "Draco",
                  "age": 2
            }
         ]
      }
      
    3. [
         {
               "type": "dog",
               "name": "Bernie",
               "age": 3
         },
         {
               "type": "cat",
               "name": "Draco",
               "age": 2
         }
      ]