Beautiful JSON (JavaScript Object Notation)

JSON (JavaScript Object Notation)

It is a lightweight data exchange format. It is easy for human read and writes. JSON is in text format which is completely language independent.

The JSON format was originally specified and developed by Douglas Crockford and is described in RFC 4627 license. The JSON filename extension is .json.

1. Objects: Objects begin and end with curly braces ({}).

2. Object Members: Members consist of strings and values commas(,) separated

3. Arrays: Arrays begin and end with braces and contain different values.

4. Values: A value can be a string, can be an object, an array, or the literals

5. Strings: Strings are surrounded by double quotes and contain the Unicode colon (:). Members are separated by commas(,). Values are separated by commas(,). true, false or null.character or common backslash escapes.

Google Trends JSON Over XML

Beautiful JSON (JavaScript Object Notation)

JSON is built on 2 structures

  1. It is a collection of name/value pairs in a different language it is considered as the dictionary, object, record or struct.
  2. It is an ordered list of values that is realized as an array, list or sequence.
{
  "employees": {
    "employee": [
      {
        "id": "1",
        "firstName": "Tom",
        "lastName": "Cruise"
      },
      {
        "id": "2",
        "firstName": "Maria",
        "lastName": "Sharapova"
      },
      {
        "id": "3",
        "firstName": "James",
        "lastName": "Bond"
      }
    ]
  }
}
Beautiful JSON (JavaScript Object Notation)

In this example, you can see that we assign JSON data to x variable and it is treated as the object. By putting the dot(.) operator you can access the properties of that object.

Best Advantage Of JSON

  1. Format is simple
  2. When you give that JSON data to a variable it becomes the object.

DataTypes in JSON

  • a string
  • a number
  • an object (JSON object)
  • an array
  • a boolean
  • null

Below are some examples of JSON datatype

JSON Strings

{ "name":"Sagar" }

JSON Numbers

{ "age":32 }

JSON Objects

{
"employee":{ "fullname":"Sagar Jaybhay", "age":32, "city":"Pune" }
}

JSON Arrays

{
"employees":[ "sagar", "Ram", "Lakhan" ]
}

JSON Booleans

{ "sale":true }

JSON null

{ "middlename":null }

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *