Skip to content
  • Facebook
GeekCer Logo

GeekCer

The geek's Coding education and Review centre

  • Home
  • Tutorials
    • Java
    • Servlet
    • JSP
    • Python
    • C Tutorial
    • Spring
    • Spring Boot
    • MongoDB
    • Hibernate
    • Data Structure
  • General Knowledge
  • Biography
  • Grammar
  • Festival (त्योहार)
  • Interview
  • Differences
  • Important
  • Toggle search form

Home » Important » JSON The Data Interchange Standard Format

  • Spring Boot Tutorial
    Spring Boot Tutorial Spring Boot
  • Indian Constitution भारतीय संविधान | भारत का संविधान
    Indian Constitution भारतीय संविधान | भारत का संविधान Important
  • Top 100 C programs for geeks
    Top 100 C programs for geeks C Language
  • Java Operators
    Java Operators Java
  • Kishore Kumar Biography in Hindi | किशोर कुमार की जीवनी
    Kishore Kumar Biography in Hindi | किशोर कुमार की जीवनी Biography
  • Most Popular Hibernate Interview Questions and Answers
    Most Popular Hibernate Interview Questions and Answers Hibernate
  • HTML Tutorial
    HTML Tutorial Important
  • Loop in Java
    Loop in Java Java

JSON The Data Interchange Standard Format

Posted on September 20, 2021October 4, 2021 By admin No Comments on JSON The Data Interchange Standard Format
JSON The Data Interchange Standard Format

JSON is a lightweight data format in which we store information in an organized manner. We can access the data JSON format easily.

The full form of JSON is JavaScript Object Notation. The JSON text format does not depend on any programming language. It is programming language independent. We can use this data format in C, C++, C#, Java, JavaScript, Perl, Python and many other languages.

JSON is a collection of name-value pairs, which means we store information as name-value pairs. Most programming languages today support the JSON data structure. These days we are transferring huge amount of data. And the JSON format is the best data structure for this purpose.

Table of Contents

  • Why should we use JSON?
    • Where does the JSON file come from?
  • Rules for writing JSON format
  • Example of JSON format file
    • Syntax of JSON format
    • How to open JSON format file?
  • Data Types in JSON
    • 1) Number
    • 2) String
      • Special characters that we can use in strings of a JSON document
    • 3) Boolean
    • 4) Object (JSON Objects)
    • 5) Array
    • 6) Null
  • Difference between JSON and XML
    • JSON format
    • XML format

Why should we use JSON?

  • JSON format is easy to read and write.
  • The syntax of JSON is very simple and very straightforward.
  • All major JavaScript frameworks support JSON, so you don’t need to worry about it if you’re using a framework.
  • Most importantly, it is language independent. If you have idea about JSON then you can work with JSON in any programming language.
  • JSON supports arrays, objects, strings, numbers, and values.

Where does the JSON file come from?

JSON was derived from the JavaScript programming language. But most of the programming languages nowadays have a generator and parser of JSON format data.

Rules for writing JSON format

  • You should write the information in name-value pairs like {“Company”:”Geeks Company”}.
  • You should use colon (‘:’) to separate name and value.
  • If you have multiple data then you should separate the data using comma (“,”).
  • If you are preparing data in JSON format, it means you are creating JSON object. You should use curly braces to enclose objects.
  • If you need array of data you should use square brackets.
  • The JSON format does not allow commas at the end of the last pair-value pair. If you try to add at the end it will come under syntax error of JSON format.

If you are creating JSON information and want to put it in a file, you should have the extension .json. .json extension is not mandatory you can have .txt also.

You can learn Agile Methodology of Software Development.

Example of JSON format file

We are taking example of JSON file which will contain employee information which includes name and email.

Syntax of JSON format

Employee.json

                  {"employees":[  
    {"name":"BLAKE", "email":"blake@gmail.com"},  
    {"name":"CLARK", "email":"clark@gmail.com"},  
    {"SMITH":"John", "email":"smith@gmail.com"},
    {"TURNER":"John", "email":"turner@gmail.com"}   
]}  

How to open JSON format file?

You can open the JSON file with any text editor like Notepad, Notepad++ etc. If you want to view formatted data you can open json file in Mozilla Firefox (as it is widely used).

How to open JSON file?

Data Types in JSON

The following are the important data types JSON we use frequently:

1) Number

We can use this data type if we want to use a real number, an integer or a temporary number.

                  { "age" : 25 }

2) String

If we want to write 0 or more Unicode characters then we can write inside double quotes. And we can also write the escaping character inside double quotes.

                  { "name" : "Mark" }

Special characters that we can use in strings of a JSON document

#CharactersDescription
1“”double quotation
2\back slash
3/forward slash
4bbackspace
5fform feed
6nnew line
7rcarriage return
8thorizontal tab
9ufour hexadecimal digits

3) Boolean

This data type represents either true or false values. Apart from this data type will not support.

                  {"active" : "true"}

4) Object (JSON Objects)

It is a collection of name-value pairs separated by commas and placed inside curly brackets.

                  {
"employee":{ "name":"Clark", "age":31, "city":"New York" }
}

5) Array

We enclose the sequence of values in square brackets. And we also separate each value with a comma.

                  {
"employees":[ "Mark", "Clark", "Smith" ] 
}

6) Null

It represents the empty value. Sometimes we do not have value to hold, in which case we use null .

                  { "lastname" : null }

Difference between JSON and XML

#JSONXML
1JSON stands for JavaScript Object Notation.XML stands for eXtensible Markup Language.
2JSON object has data type.XML data is type less. It does not have data type.
3JSON types may be string, number, array, Boolean etc.But in XML, data should be in string format.
4JSON is easy to learn and simple to read and write. XML is less easy than JSON and less simple than JSON.
5JSON is data-oriented.But XML is document-oriented.
6JSON supports array concept.But XML does not support array.
7JSON is less secured as compared to XML.It is more secure than JSON.
8You can parse JSON by a standard JavaScript function. But you can parse XML with an XML parser.
9JSON files are more human readable than XML.XML files are less human readable than JSON.
10JSON does not support comments.But XML support comments.

JSON format

                  {"Cricketers":[
  { "firstName":"Virat", "lastName":"Kohli" },
  { "firstName":"Kane", "lastName":"Williamson" },
  { "firstName":"M.S.", "lastName":"Dhoni" }
]}

XML format

                  <Cricketers>
  <Cricketer>
    <firstName>Virat</firstName> 
    <lastName>Kohli</lastName>
  </Cricketer>
  <Cricketer>
    <firstName>Kane</firstName> 
    <lastName>Williamson</lastName>
  </Cricketer>
  <Cricketer>
    <firstName>M.S.</firstName> 
    <lastName>Dhoni</lastName>
  </Cricketer>
</Cricketers>

JSON was initially developed to meet the need for stateless, server-to-browser communication without using browser plugins.

In conclusion, Hope you guys understood the basics about JSON file format. And in this article we have also covered the syntax of JSON with supported data type, example of JSON. Apart from this, you also got an idea of the difference between JSON and XML which are two different types of file formats.

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • More
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)

Also Read

Important Tags:Data Types, Difference between JSON and XML, JSON Format, Language Independent, String, XML

Post navigation

Previous Post: Agile Methodology of Software Development
Next Post: Design Pattern in Software Engineering

More Related Articles

Immutable class in Java Immutable class in Java | How to create Immutable class in Java Important
Difference between Bugs, Errors and Issues in Software Testing Difference between Bugs, Errors and Issues in Software Testing Important
Join Queries in Oracle, Sql Joins, Self, Inner, Outer, Equi Join Queries in Oracle, Learning Advance Sql Joins, Example Important
How to become a Chief Financial Officer (CFO) How to become a Chief Financial Officer (CFO)? Important
What is Insurance with full details? What is Insurance with full details? | Life, Health, Car Insurance Important
What is Computer What is Computer? Important

Related Posts

  • Immutable class in Java
    Immutable class in Java | How to create Immutable class in Java Important
  • Difference between Bugs, Errors and Issues in Software Testing
    Difference between Bugs, Errors and Issues in Software Testing Important
  • Join Queries in Oracle, Sql Joins, Self, Inner, Outer, Equi
    Join Queries in Oracle, Learning Advance Sql Joins, Example Important
  • How to become a Chief Financial Officer (CFO)
    How to become a Chief Financial Officer (CFO)? Important
  • What is Insurance with full details?
    What is Insurance with full details? | Life, Health, Car Insurance Important
  • What is Computer
    What is Computer? Important

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Structured Vs Unstructured Data in Hindi | Key Difference
  • Jhansi Ki Rani Lakshmi Bai History, Story, Information in Hindi
  • Elon musk Hindi : एलन मस्क हिंदी में, Autobiography,  Net Worth
  • World Environment Day in Hindi : Objective, Importance, Theme
  • Thomas Edison Biography in Hindi – थॉमस एडिसन जीवनी
  • International Nurses Day in Hindi | नर्स दिवस क्यों मनाते हैं?
  • Fork/Join Framework in Java | RecursiveTask, RecursiveAction
  • DBMS in Hindi | DBMS क्या है? | DBMS की विशेषताएं और प्रकार
  • Spring Boot Tutorial
    Spring Boot Tutorial Spring Boot
  • Indian Constitution भारतीय संविधान | भारत का संविधान
    Indian Constitution भारतीय संविधान | भारत का संविधान Important
  • Top 100 C programs for geeks
    Top 100 C programs for geeks C Language
  • Java Operators
    Java Operators Java
  • Kishore Kumar Biography in Hindi | किशोर कुमार की जीवनी
    Kishore Kumar Biography in Hindi | किशोर कुमार की जीवनी Biography
  • Most Popular Hibernate Interview Questions and Answers
    Most Popular Hibernate Interview Questions and Answers Hibernate
  • HTML Tutorial
    HTML Tutorial Important
  • Loop in Java
    Loop in Java Java
  • Java Tutorial
  • Servlet Tutorial
  • JSP Tutorial
  • Maven Tutorial
  • HTML Tutorial
  • Programs
  • Hindi/English Grammar
  • Difference Between ... and ...
  • HR Interview
  • Important Articles

Write to Us:
geekcer.code@gmail.com

  • About Us
  • Privacy and Policy
  • Disclaimer
  • Contact Us
  • Sitemap

Copyright © GeekCer 2022 All Rights reserved