From EduTechWiki - Reading time: 2 min
“JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.” (JSON, retrieved 19:07, 15 May 2007 (MEST)).
“JSON (JavaScript Object Notation) is a lightweight computer data interchange format. It is a text-based, human-readable format for representing objects and other data structures and is mainly used to transmit such structured data over a network connection (in a process called serialization). JSON finds its main application in AJAX web application programming, as a simple alternative to using XML for asynchronously transmitting structured information between client and server.” ([1], retrieved 19:07, 15 May 2007 (MEST))
JSON is a subset of the object literal notation of JavaScript. Since JSON is a subset of JavaScript, it can be used in the language with no muss or fuss.
JSON supports several data types including:
{
"anInt": 5555,
"aFloat": 55.055,
"aString": "testing",
"aBoolean": true,
"anArray": [1, "2", 3.34, "dog"],
"anObject": {
"prop1": "a value",
"prop2": "another value",
"prop3": -9999 }, "aNull": null
}
JSON is built on two structures (JSON website, retr. May 2007):
var myJSONObject = {"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.
myJSONObject.bindings[0].method // "newURI"