JSON Data

JSON Data - In JSON, the data are in key/value pairs. Key and value is separated by a colon :. JSON value must be of the following data types:String, Number, Object (JSON object), Array, Boolean, NULL

Please keep in mind that JSON value does not support the following data types: function, date, undefined.

Let us understand each of the data types.

JSON Strings

JSON value having data type string, must be written inside the double quotes.

General Syntax

      
    
Try it now

Source Code

          
            <script type="text/javascript">
'{"game":"cricket","event":"mumbai"}'
</script>          
        
Try it now

JSON Numbers

JSON value having data type number must be written without double quotes and it will be of integer or floating-point.

Source Code

          
            <script type="text/javascript">
'{"name":"rice","price":50}'
</script>          
        
Try it now

JSON Objects

JSON data value type might be an object.

Source Code

          
            <script type="text/javascript">
{"users":{"name":"Smith", "age":45, "city":"Gorakhpur"}}
</script>          
        
Try it now

JSON Arrays

JSON data value can be array. Let us understand it with the help of an example

Source Code

          
            <script type="text/javascript">
{
"uesrs":["Smith", "Jane", "Doe"]
}
</script>          
        
Try it now

JSON Booleans

JSON data value can be either true or false.

Source Code

          
            <script type="text/javascript">
{"test":true}
</script>          
        
Try it now

JSON null

JSON data value can be null.

Source Code

          
            <script type="text/javascript">
{"test":null}
</script>          
        
Try it now

Web Tutorials

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