JSON - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

JSON DataTypes

JSON DataTypes

shape Description

The data type in a programming dialect is an arrangement of information with values having predefined attributes such as integer, follwoing is the general syntax for the data type. [html]data type variable=10;[/html] Following is an example of the data type. [html]int splessons=10;[/html] In the above example, int is the datatype, splessons is the variable, 10 is the value of the variable. Following are the datatypes of JSON.
Datatypes Description
Object Collection of key:value pairs, these are unordered.
Array Values in a sequence order.
Value It may be any thing like String, number, value, etc.
Boolean To return true or false.
Number It used as double- precision floating-point format in JavaScript language.
String It is nothing but sequence of more zeros or more double quoted Unicode characters.

shape Conceptual Figure

Following is an image to represent the data types of JSON.

Number Datatype

shape Description

The number type represents the set of all possible numeric values recognized by the JavaScript language., Number datatype used as double- precision floating-point format in JavaScript language. Hexadecimal and Octal formats are not utilized. Following is the syntax for the Number datatype.
var json-object-name = { string : number_value, .......}
Following is an example. [html]var obj = {age: 23}[/html]

String Datatype

shape Description

The string sort speaks to the arrangement of all conceivable string values whereby a string worth is a limited representation that incorporates at least 0 Unicode characters. while the character encoding is entirely viewed as that of Unicode, string qualities can likewise be illustrative of ASCII character encoding. This is on the grounds that ASCII is a subset of the Unicode character set. String datatype is nothing but a sequence of more zeros or more double quoted Unicode characters. Here the character is a single character string. Following is the syntax for the String datatype.
var json-object-name = { string : "string value", .......}
Following is an example. [html]var obj = {name: 'Sachin'}[/html]

Boolean Datatype

shape Description

A Boolean speaks to a legitimate esteem comprising of just two conceivable values. Those qualities are either true or false. While these are two conceivable qualities that can be relegated, a Boolean sort is usually returned as the assessment of a condition. Following is the syntax for the Boolean datatype.
var json-object-name = { string : true/false, .......}
Following is an example. [html]var obj = {name: 'Sachin', age: 23, allowed: true}[/html]

Array Datatype

shape Description

Array datatype is an ordered collection of values, as know that array indexing will be start from 0 and 1. Following is the syntax for the Array datatype.
[ value, .......]
Following is an example. [html]["JANUARY", "FEBRUARY", "MARCH", "APRIL"] [/html]

Object Datatype

shape Description

Object datatype is nothing but collection of key:value pairs. Following is the syntax for the Object datatype.
[{ string : value, .......}
Following is an example. [html] { "SPlessons": { "name": "Enni", "ID": 513, "Tutorial": "JAVA", "Registered": true } } [/html]

Whitespace Datatype

shape Description

Whitespace datatype is used to place between pair of elements. Following is the syntax for the Whitespace datatype.
{string:" ",....}
Following is an example. [html] var i = " splessons"; var j = " web site" [/html]

null Datatype

shape Description

The null speaks to the purposeful absence of an esteem. This is in spite of the indistinct esteem, which speaks to no esteem as having been set. The null sort is an esteem utilized unequivocally to represent an empty reference. Following is the syntax for the null datatype.
nul
Following is an example. [html] var k = null; if(k == 1){ document.write("<h1>value is 1</h1>"); } else{ document.write("<h1>value is null</h1>"); } [/html]

Summary

shape Key Points

  • JSON does not support comments.
  • Hexadecimal and Octal formats are not utilized in JSON.
  • In array each value will be separated with comma.