I am relatively new to web development and web applications. I have heard about JSON but am not sure exactly what its uses are.
-
possible duplicate of [What is JSON and why would I use it?](http://stackoverflow.com/questions/383692/what-is-json-and-why-would-i-use-it) – Nikhil Agrawal Jan 08 '14 at 19:40
3 Answers
JSON is a format for encoding information returned by the server. When you call a script with AJAX/XHR (e.g. with JavaScript) the returned information can come via XML, JSON, or another format. JSON is simply a way to return that data in an object structure native to JavaScript - in a way that generally doesn't require a lot of parsing, like XML does.
-
1+1 JSON is a *subset* of JavaScript object literal notation is well suited to modeling objects composed of dictionaries, lists and primitive values -- especially JavaScript objects. A JSON parser (turns JSON into JavaScript objects, for instance) is therefor a direct transformation. XML, on the other hand, generally isn't able/used to provide this simple mapping and generally requires a conversion/extraction from the XML document or fragment. This *simplicity* is one of JSON's biggest strengths. – Mar 04 '11 at 23:40
It is a kind of language for encoding information. For example, if you want to send information about person from one place to another, then it JSON it may look like this:
{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address":
{
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021"
},
"phoneNumber":
[
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "fax",
"number": "646 555-4567"
}
]
}
Taken from wiki. :) See http://en.wikipedia.org/wiki/JSON for more details.

- 54,167
- 9
- 132
- 169
First, it's an acronym for JavaScript Object Notation.
It is often used in places where applications deal with object data structures (often seen in languages such as Java, C#, etc.), and associative arrays (key-value pairs seen in many languages such as Python, PHP, etc.)
To answer your question, it's a simple and efficient way to encode objects into strings, transfer them, and recreate the objects on the other end.

- 3,014
- 3
- 26
- 27