JSON Data Types

JSON (JavaScript Object Notation) is a very light data exchange language. It is a human-friendly language, it means you can easily read and write it, and also it is very easy to learn. JSON is a java  language which  is very easy for the gadgets to determine and perform the execution on it. There are different examples for the JSON data types that we are mentioning here.It is a text format and fully language independent. JSON also uses some features of the most popular languages such as C, C++, Java and many other languages. In the JSON programming language, there are different kinds of Data Types . These are mainly  string, number, Boolean, null, object, and Array. Object and Array come in the structured Data Types and others come under the primitive Data Types.

JSON Data Types

Primitive Data Types

  1. Number
  2. String
  3. Null
  4. Boolean
  5. Value
  6. Whitespace

 

JSON Values

Number

With the Number Data Types in the JSON programming language, there are some points that you must have to follow at the time of programming.

  • Number is a dual precision float format in the JavaScript and it always depends on its implementations. It is a primitive Data Type.  Infinity never occurs in this Data Types.
  • In the Number Data Types , it uses some different types of number such as an Integer that have 0 -9 digits and also may be any positive and negative numbers.
  • Fraction also comes in the Number Data Types that can be in the form of 3.14 or 4.55 etc.
  • Exponent  also comes in the Number Data Types.

String

String is also a primitive Data type. String is a queue of 0 or more dual quoted Unicode character and also must have a backslash escaping. In this language, character means strings which have one maximum length. These are the escape sequence of the String Data Type.

  • (\) is a reverse solidus that used in the string for reverse.
  • (/) it is called the solidus.
  • (b) It is used for the backspace.
  • (f) It is used for the form feed in the String.
  • (n) It is used for the new line.
  • (r) It is used for the carriage return.
  • (t) It is used for the horizontal tab.
  • (u) It is used for the four hexadecimal digits.

Example

Var   obj  =   { name: ‘Deepak’}

Boolean 

Boolean is based on the concept of true and false. The outcome of the Boolean expressions is always in the form of true and false, never else.

Example

Var  json =  { name : ‘Deepak’, marks : 99, Distinction : true}

Whitespace 

Generally it is used to make your program or software code very easier to understand. But sometime it is used with different purposes.

Syntax

{ string : “    “,………}


Example

var  k =  “ Anurag”;
var  l = ”Daniel”;


Null Data type

A null data types means, a Data type that have no any value.

Syntax

null

Example

var  k = null;
if (k==1);
 {
    document .write(“<h1> k is equal to the 1 </h1>);
}
 else
  {
      document .write(“<h1> k is equal to the null<h1>”);
}


Value

A value can be number (positive integer or negative integer and positive float or negative float value), string, object, null, and Boolean.

Syntax

Number  , String , Array , null , true |,false

Example 

var  j =5;
var  k = “Deepak”;
var  m = null;

JSON Structured Data Types 

Array

Array is a collection of variable having similar Data Types. It is a structured Data Type. Array is also divided into several types such as one, two or multi-dimensional array. In the array, index starts from the zero and go to desired number . In the array, each value is separated by the comma (,). It is used when many variables  are required in the similar types. The dimension is mentioned in the opening and closing square brackets [       ].

Array syntax

ar [value…]

Examples of Array 

{
  “student” : [
        {  “jon “ : “class” , “seven”   },
        {  “peter”  :  “class”, eight” },
         { “alex “ : “ class” ,second” }
        ]
}

Object 

Object is a real-world entities that have some characteristics and behavior. Objects are never in an order. Object are enclosed by the curly braces as {and end with as}.

Example

{
  “name” : “Deepak”,
  “course” : “BCA”,
   “semester” : “ fifth”,
}