What is JSON

In JSON tutorial, learn various concepts about JSON such as difference with XML, syntax and data types, read & write JSON and convert JSON to string and vice-versa etc.

JSON (JavaScript Object Notation) is the most widely used data format for data interchange on the web. This data interchange can happen between two computer applications at different geographical locations or running within the same machine.

The good thing is that JSON is a human-readable as well as a machine-readable format. So while applications/libraries can parse the JSON documents – humans can also look at the data and derive the meaning from it.

All modern programming languages (e.g., Java, JavaScript, Ruby, C#, PHP, Python, and Groovy) and application platforms provide excellent support for producing (serializing) and consuming (deserializing) JSON data.

1. JSON Specifications

Douglas Crockford originally created JSON in 2001, and initially standardized it in 2006 under RFC 4627 through the IETF. In 2013, Ecma International also standardized JSON under ECMA 404.

In March 2014, Tim Bray corrected errata with the original IETF 4627 in IETF RFC 7158 and RFC 7159.

The new specifications remove inconsistencies with other specifications of JSON, repairs specification errors, and offer experience-based interoperability guidance.

2. JSON File and MIME Type

The standard file type for storing a JSON document in the filesystem is .json.

JSON’s Internet Assigned Numbers Authority (IANA) media (or MIME) type is application/json.

3. JSON Document

A JSON document may contain text, curly braces, square brackets, colons, commas, double quotes, and maybe a few other characters.

Primarily, a valid JSON document can contain two structures:

  1. An Object surrounded by curly braces and containing multiple name/value pairs. In various languages, this is realized as an record, struct, dictionary, hash table, keyed list, or associative array.
  2. An Array or Ordered list of values surrounded by square brackets. In most languages, this is realized as an vector, list, or sequence.

4. JSON Example

An example JSON document is:

//JSON Object

{
	"employee": {
		"id": 1,
		"name": "Admin",
		"location": "USA"
	}
}

//JSON Array

{
	"employees": [
		{
			"id": 1,
			"name": "Admin",
			"location": "India"
		},
		{
			"id": 2,
			"name": "Author",
			"location": "USA"
		},
		{
			"id": 3,
			"name": "Visitor",
			"location": "USA"
		}
	]
}

As we can see, the JSON document consists of name/value pairs. These name/value pairs reflect the structure of the data.

5. Learning JSON

In this JSON tutorial, we will learn the various concepts about JSON, with examples.

  • Difference between JSON and XML
  • JSON Syntax and document types
  • How to read JSON document
  • How to write JSON document
  • Converting JSON to String and vice-versa etc

Ref: Introducing JSON

Comments

Subscribe
Notify of
guest
8 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Shubham

As you can see, JSON data consists of name/value pairs. These name/value pairs reflect the structure of the data.

Vince Villafuerte

does this compatible to all programming language?

Ace Rivers

When looking at JSON request URL, how do I identify the endpoint?

Shubham

Why JSON is better than XML?

Shubham

does this compatible to all programming language?

relascope

You have it as a string and can parse it.
So… Yes.