In Developer

Gone are the days when web services were using XML to transmit data and used XML as the primary data format. Since JSON has been documented, it has captured the world of transmitting data as it is way more lightweight than XML. JSON stands for JavaScript Object Notation; it became popular in the '80s for being used in video games making in Atari.

What is JSON

The popularity of JSON increased and over the next 20 years, it started replacing XML (Extensible Markup Language) for exchanging data. If we talk about the notations, JSON is written in the English language and more readable than other programming languages.

All about JSON

JSON is a data format and syntax to exchange and store data. When a web browser and a server exchanges data, the data is in text format. Therefore, JSON is a text. JavaScript objects are converted into JSON and send the JSON format to the server. JavaScript objects are used this way with data without having the need for complicated translations and parsing of JavaScript language.

Keys and values are the two primary things that JSON is made of. Basically, in a simple sentence JSON, I comprised of key/value pairs.

  • Key – Key is a string that is enclosed inside quotations and it is always a string
  • Value – Values can be anything starting from string to an array, Boolean expressions, an array of objects, number, strings, a number, or simply an object.
  • Key-value Pair – JSON notation is like ["key” : “value” ]. So, here key and value make a pair and conjugated with a colon in between. These are comma separated.

json notation

Image Source: www.json.org

In JSON object is depicted as a set of key/value pair which is unordered. Similarly, Array can be written in JSON like –

json notation

Image Source: www.json.org

And values in JSON are –

all about json

Image Source: www.json.org

Example of Sending Data in JSON


Image Source: Script editor of www.w3schools.com

Difference between json and xml - What you must know. 

XML and JSON both are used for transfer and to receive data to and from web servers. XML and JSON both have formats that are human-readable, use a hierarchical structure that is the value inside value structure, can be used by many programming languages, can be parsed well, and can be used with an XMLHTTP Request.

But JSON is not XML. They are different in many ways. The main difference between XML and JSON is a way of parsing. Parsing of XML is very complicated, takes time and it needs XML parser to be parsed. On the other hand, JSON is parsed by JavaScript functions easily and takes lesser time. JSON is parsed into a JavaScript object which can be used as it is.

This is not the only reason that JSON is better than XML. JSON is shorter and does not use ending tags, which makes the parsing faster. Also, JSON is faster to read and write than XML tags and it can use arrays for a bunch of objects to define.

When it comes to AJAX applications, JSON works faster and efficiently than XML. To use XML for AJAX, it needs to fetch an XML document, XML Dom to be used to loop through the intended document, then finally extraction and storage of the variables are done from it. On the other hand, it is just a two-step process for JSON. The JSON string is just needed to be fetched and parsed and that’s it.

JSON Object vs. JavaScript Object

The name JSON is inspired by JavaScript object notation but there is a difference between JSON and JavaScript objects. JSON is basically plain text, or we can say string format representation of an object more technically. It can be used by any programming language and not by JavaScript only. However, it can be converted into a JavaScript object and used.

JavaScript is an object-oriented programming language that is used for client-side scripting. JSON is a data exchange format and not a full-fledged programming language that creates and uses objects. There is nothing like JSON objects. JSON uses strings or text and can be parsed by any programming language to make an object and use it.

Here is an example to understand this well:

var a = ‘{“Key” : 123}’ ;   (JSON)

var b = {“Key” : 123} ;      (JavaScript)

In the above example, both variables look the same. But, if we look closer, we can notice that ‘a’ is actually a string and it is a JSON string. ‘b’ is a JavaScript object. Both look very similar, thus ‘a' can be misinterpreted as a JSON object.

Now, we can parse ‘a’ into a javascript object using JSON.parse() function:

var c = JSON.parse(a);

What is a JSON API?

If you want to build an API (application program interface) in JSON, JSON API is the specification for that. These conventions and specifications are used to increase productivity and efficiency of JSON, your API and over these, your application.  JSON APIs can be used in web development using JAVA, or WordPress plugin development which can send WordPress emails, etc.

JSON APIs can be customized and built by clients and used to serve specific purposes in a better way. For example, Pepipost has JSON APIs that are built for email services provided to clients.

Pepipost has two types of APIs –

  1. REST API – These APIs accept each parameter as a separate HTTP variable. Example -

Image Source: pepipost.com

  1. JSON APIs – These APIs accept parameters in JSON string format that is provided as a value of a string parameter. Example –

Pepipost APIs help to connect Pepipost to a CMS, any application server, blogging platforms like WordPress to send emails instantly. Developed customized HTTP API can send thousands of emails in just one API call and just one API is sufficient for multiple email addresses. This feature greatly reduces the bandwidth cost for clients. Also, it provides stats of how many emails are sent, spam levels and how many emails have been bounced while delivering. This data can be used to analyze the email delivery status of your application.

The primary category of this API is Email. This API has three parts – API URL, API Key, and Input data. Each call of this API has to be authenticated using a unique API key for security purposes. It supports SSL. Inputs values can be entered through parameters defined. This is a hypermedia API and supports response formats like XML, JSON, and SMTP.

Found This Blog Interesting, Please Rate This Blog 1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4.00 out of 5)
Recommended Posts

Leave a Comment

We are always looking for fresh talent to contribute to our blog. If you have a knack for writing and a passion for email marketing, we would love to have your post on our Guest Blog .

Submit a Guest Post
Pepi thinking

Start typing and press Enter to search

Pin It on Pinterest