ibvasi
7/12/2018 - 4:02 AM

JSON data types #jsondatatypes

JSON data types #jsondatatypes

/*
 * JSON syntax is derived from JavaScript object notation syntax:
 * Data is in name/value pairs
 * Data is separated by commas
 * Curly braces hold objects
 * Square brackets hold arrays
 * In JavaScript values can be all of the above, plus any other valid JavaScript expression, including:
 * a function
 * a date
 * undefined
 */

/* JSON data types:
 * Number, string, boolean, object, array and null
 */

// Number
var number = {"age": 20};

// String
var string = {"name": "Robert"};

// Boolean
var boolean = {"passed": true};

// Object
var object = {
  "family": {
    "name": "Robert",
    "age": 20,
    "passed": true
  }
};

// Array
var array = {
  "family": ["Robert", "Mike", "Patrick"]
};

// Null
var empty = {
  "education": null
};