Home > JSON > JSON – Part 2

JSON – Part 2


In the previous blog post, I have explained about JSON. In this post, I am going to show you the different data types in JSON.

In JSON, we have to enclose a value within double quotes. Example: “SQL Server”. There are different types of value that we can store in JSON format file.

  1. string
  2. number
  3. object
  4. array
  5. true
  6. false
  7. null

string: It is a collection Unicode character(s). We also have some control characters, If you are a C programmer then you should have use these characters in printf statement. Escape sequence or control characters are used to define some characters in a value by using \ (slash).

Control characters in JSON are:

  • \”
  • \\
  • \/
  • \b
  • \f
  • \n
  • \r
  • \t
  • \u four-hex-digits
Example:
“\”SQL Server\””

number: It is a collection numeric digits from 0 to 9. We can also use signs such as – (negative), + (positive). The Dot (.) is used to represent decimal number. We can also represent exponential numbers using e or E as given in this collection (e, e+, e-, E, E+, E-)

Example:
{
“PI”: “3.14159265359”,
“exp”: “3.14e+”
}

Object: It is a collection of name and value. it is enclosed within {}

Example:
{
“first name”: “Ayyappan”,
“last name”: “Thangaraj”
}

Array: It is a collection of items. It is enclosed within []

Example:
[“ASM”, “C”, “C++”, “C#”]

true and false: These are Boolean values

Example:
{“Boolean”: [“true”, “false”] }
null : It is a  null value

Example:
{“SSN”:”null”}

 

Advertisements
Categories: JSON Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: