go to  ForumEasy.com   
JavaPro  
 
 
   Home  |  MyForum  |  FAQ  |  Archive    You are not logged in. [Login] or [Register]  
Forum Home » JavaScript » What's JSON?
Email To Friend  |   Set Alert To This Topic Rewarding Points Availabe: 0 (What's this) New Topic  |   Post Reply
Author Topic: What's JSON?
WebSpider
member
offline   
 
posts: 147
joined: 06/29/2006
from: Seattle, WA
  posted on: 09/21/2013 06:23:30 PM    Edit  |   Quote  |   Report 
What's JSON?
JSON stands for JavaScript Object Notation. It is a text-based open standard designed for human-readable data interchange, just like LDIF or XML.

 Profile | Reply Points Earned: 0
WebSpider
member
offline   
 
posts: 147
joined: 06/29/2006
from: Seattle, WA
  posted on: 09/21/2013 06:35:14 PM    Edit  |   Quote  |   Report 
JSON's Syntax
JSON's structural characters:
  1)  {
  2)   } 
  3)  [ 
  4)   ]
  5)  :
  6)  ,


JSON's basic types:
  1) Number       -- 123
  2) String       -- "abc"
  3) Boolean      -- true or false
  4) Array        -- [ <any>, ... ]
  5) Object       -- { "attrName":<any>, ... } 
  6) null         -- <empty>


 Profile | Reply Points Earned: 0
WebSpider
member
offline   
 
posts: 147
joined: 06/29/2006
from: Seattle, WA
  posted on: 09/21/2013 06:42:01 PM    Edit  |   Quote  |   Report 
JSON Example
For example, a person's contact information can be represented in JSON as follows:
contact::=
{
    "firstName": "John",
    "lastName": "Smith",
    "age": 25,
    "married": true,
    "address": {
        "streetAddress": "123 Main Street",
        "city": "New York",
        "state": "NY",
        "postalCode": "10021"
    },
    "email": [ "jsmith@yahoo.com", "jsmith@gmail.com" ],
    "phoneNumber": [
        {
            "type": "home",
            "number": "212 555-1234"
        },
        {
            "type": "fax",
            "number": "646 555-4567"
        }
    ]
}


It can be deserialized into object by JavaScript's eval()
  var p = eval("(" + contact + ")");

or JSON's parse()
  var p = JSON.parse(contact);


 Profile | Reply Points Earned: 0

 
Powered by ForumEasy © 2003-2005, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.