Friday, August 26, 2011

What is JSON?

JSON stand for Java Script Object Notation, is a text base format, that contains the value in key value pair.

JSON can be used as

var objJSON = {"bindings": [
{"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"},
{"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"},
{"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"}
In this example, an object is created containing a single member "bindings", which contains an array containing three objects, each containing "ircEvent", "method", and "regex" members.

Members can be retrieved using dot or subscript operators.

objJSON.bindings[0].method // "newURI"

No comments: