JSON Array

JSON Array - It can store multiple values of type string, number, object, array, boolean, or null.JSON value must be separated by a comma and it is always placed inside the square bracket[].

JSON Array is of different types such as JSON array of string, JSON array of numbers, JSON array of Booleans, JSON Array of Objects, and JSON multidimensional array.

JSON Array Of String

Let us see the example of JSON string data.

    
     '["Ford", "BMW", "Fiat"]'
   

Inside the JSON string,a JSON array literal is exist.

    
      ["Ford", "BMW", "Fiat"]
   

From the above JSON literal, it is clear that JSON literal is similar to a Javascript array.

Please keep in mind that array values can be of different types such as string, number, boolean, object, array, null, etc.

Formation Of Javascript Array From JSON Literal

Source Code

          
            var fruits = ["orange", "grapes", "mango"];          
        
Try it now

Converting Javascript Array From JSON String

Accessing Array value through index such as ArrayName[index];

Javascript array can be created easily by parsing JSON string.

Source Code

          
            var fruits = '["mango", "orange", "banana"]';
jsArrayOffruits = JSON.Parse(fruits);          
        
Try it now

Accessing Array Inside Object

Source Code

          
            var users = '{"name":"Smith", "age":30, "fruits":["mango", "orange", "banana"]}';
var jsObj = JSON.parse(users);          
        
Try it now

Web Tutorials

JSON Array
Html Tutorial HTML
Javascript Tutorial JAVASCRIPT
Css Tutorial CSS
Bootstrap 5 Tutorial BOOTSTRAP 5
Bootstrap 4 Tutorial BOOTSTRAP 4