REST API Tutorial

  • REST
  • JSON
  • Dark Mode

Introduction to JSON

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

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

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

Primarily, JSON is built on two structures:

  1. A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
  2. An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

JSON Example

A sample JSON document looks like this:

//JSON Object

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

//JSON Array

{  
    "employees": [
    			 {  
			    	"id":    		1,
			        "name":     	"Admin",   
			        "location":   	"USA"
			     },
			     {  
			    	"id":    		2,
			        "name":     	"User",   
			        "location":   	"USA"
			     },
			     {  
			    	"id":    		3,
			        "name":     	"User2",   
			        "location":   	"USA"
			     }
    ]  
}

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

Learn JSON

In this tutorial, we will learn various concepts about JSON with examples. Such as:

  • Difference with XML
  • Syntax and data types
  • How to read JSON data
  • How to write JSON data
  • Convert JSON to String and vice-versa etc.

Ref: Introducing JSON

TwitterFacebookLinkedinReddit

5
Leave a Reply

This comment form is under antispam protection
3 Comment threads
2 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
4 Comment authors
This comment form is under antispam protection
  Subscribe  
newest oldest most voted
Notify of
Vince Villafuerte

does this compatible to all programming language?

Vote Up0Vote Down  Reply
2 months ago
Admin

Yes.

Vote Up0Vote Down  Reply
2 months ago
Ace Rivers

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

Vote Up0Vote Down  Reply
6 months ago
Shubham

Why JSON is better than XML?

Vote Up0Vote Down  Reply
6 months ago
Admin

I wouldn’t say JSON is better. It’s simpler comparing to XML. Though XML has it’s own advantages which JSON lacks e.g. comments.

Vote Up0Vote Down  Reply
6 months ago

JSON Tutorial

  • Introduction to JSON
  • JSON Syntax
  • JSON Data Types
  • JSON Schema
  • JSON Objects
  • JSON Array
  • JSON.parse()
  • JSON.stringify()
  • JSON vs XML
  • JSON with Ajax
  • JSONPath

References

  • The dissertation by Roy Thomas Fielding
  • Uniform Resource Identifier (URI, URL, URN) [RFC 3986]
  • Internet MediaTypes
  • Web Application Description Language (WADL)

Meta Links

  • About
  • Contact Us
  • Privacy Policy

Blogs

  • How To Do In Java
Creative Commons License
This work by RESTfulAPI.net is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
wpDiscuz