JSON Stands for JavaScript Object Notation. It can be
interpreted as the syntax/naming convention of defining objects in javascripts.
Data is stored in the form of key-value pairs.
A value can be an object as well (which is again a JSON). It
supports nested objects 
Key can be set with or without a string wrapper.
var JSONObject1 = {”key” : 1, “Key2” : 2}
var  JSONObject2=
{key1: 1, key2 :2};
| 
Symbol | 
Used for  | 
| 
{} | 
Wraps the object | 
| 
[] | 
Wraps an array | 
| 
“” or | 
Wraps a string | 
| 
: | 
Key value separator or assignment operator | 
| 
, | 
Element separator on arrays or objects | 
Example:
-         
var JSONObject = {“key” : value, “key” : valye};
-         
var nestedJSONObject = {“key” : value, “key” :
{“key” : value}};
-         
var JSONObjectWith Array = {“key” : value, “key”
: [value1,value2, value3]};
Accessing properties of a JSON
var myJSONObject= {“bindings” : [
{“ircEvent” : “PRIVMSG”, “method” :
“newURI”, “regex” : “^http://.*”}
{“ircEvent” : “PRIVMSG”, “method” :
“deleteURI”, “regex” : “^delete.*”}
{“ircEvent” : “PRIVMSG”, “method” :
“randomURI”, “regex” : “^random.*”}
]
};
console.log(myJSONObject.bindings[0].method);
/*newURI */
var myJSONObject= {“bindings” : [
{“ircEvent” : “PRIVMSG”, “method” :
“newURI”, “regex” : “^http://.*”}
{“ircEvent” : “PRIVMSG”, “method” :
“deleteURI”, “regex” : “^delete.*”}
{“ircEvent” : “PRIVMSG”, “method” :
“randomURI”, “regex” : “^random.*”}
]
};
console.log(myJSONObject.bindings[0].method);
/*newURI */
 
No comments:
Post a Comment