JSON

(7 minutes reading) Interested in using JSON in your projects? Do you know what it is and what it's for? Come read our article today to learn more about this open format used for transferring structured data between a web server and a web application

JSON

(7 minutes reading)


JSON is an acronym for JavaScript Object Notation, it is a compact, open standard and independent format for simple and fast data exchange between systems.

It was specified in the 2000s by Douglas Crockford.

JSON uses human-readable text, in attribute-value format (self-descriptive nature) to transmit information in text format, widely used in web services that use representational state transfer (REST) and AJAX applications, replacing the use of XML.

It is a programming language-independent data exchange format between systems.


WHAT IS JSON?

As stated earlier, JSON stands for JS Object Notation. It is a format used to structure data in text format and transmit it from one system to another, such as in client-server applications or in mobile apps.

Another way to use it is through AJAX requests, in which the application retrieves the data stored on the hosting server without the need to reload the pages.

JSON is a file that contains a series of structured data in text format and is used to transfer information between systems.

We cannot forget that despite being originated from JavaScript, JSON is not a programming language, but a notation for data transfer that follows a specific pattern. In this way, it can be used with several programming languages.

All data that is in a JSON format file must be structured through a collection of name and value pairs, or else be an ordered list of values.

In its elements must have:

KEY – is the content identifier. Must be a String delimited by quotes.

VALUE – represents the content and can have the following data types: string, array, object, number, boolean or null.


WHAT IT IS USED FOR AND MAIN USES

I believe we all already know that data transfer between applications is done by APIs, which, among other formats, uses JSON to structure the information transmitted.

In addition, JSON is also used for AJAX requests on websites where interactions with databases are made, such as MySql.

Another way to use JSON is to manage projects in different programming languages.

Here are some of the main uses for JSON:

JSON can be used as a data format for any programming language to provide a high level of interoperability. Also, it's used a lot to store temporary data, so we're able to generate a JSON object from user-generated data like forms.

We use JSON to transfer data between systems, i.e. a database on a website has a customer's mailing address, but the address needs to be verified through an API to ensure it is valid. So, you can send the address data in JSON format to the address validation service API.

With JSON we can get the credentials to connect to a database when developing an app, as well as a log file path. These credentials and the file path can be specified in a JSON file to be read and made available.

JSON simplifies complex documents down to the components that have been identified as significant, converting the data extraction process into a predictable and readable JSON file.


JSON - ADVANTAGES

The main advantages of JSON are:

- Simpler reading;
- Easier parsing;
- Supports objects (is typed);
- Higher speed in execution and data transport;
- File with reduced size;
- Used by none other than companies like Google, Facebook, Yahoo and Twitter.


JSON x XML

JSON and XML are competitors in information exchange. Here are the main similarities between them:

- Represent information in text format;
- They have a self-descriptive nature;
- Both can represent complex information, difficult to represent in tabular format. Some examples: composite objects (objects within objects), hierarchy relationships, multivalued attributes, arrays, missing data, etc.
- Both can be used to carry information in AJAX applications.
- Both can be considered standards for data representation. XML is a W3C standard, while JSON was formalized in RFC 4627.
- Both are language independent. Data represented in XML and JSON can be accessed by any programming language, through specific APIs.

JSON is much simpler than XML and was created just for that. JSON is used by most APIs because it is lighter than XML to transport and even to build and decode, the gain can impact large volumes.

XML, on the other hand, is the preferred technology for working with metadata, capable of storing or linking data in any format, precisely because of the freedom given to the user to define the tags that make up an object.


DATA TYPES AND JSON SYNTAX

Here are the basic JSON data types:

Number - a number that can be signed, a dot-separated fractional part, and eventually use exponential AND notation, but cannot include non-numbers like NaN. There is no distinction between integers and floating-point numbers, reflecting the fact that JS stores any number as a double-precision floating-point, but other languages that implement JSON may have differences in the representation of numbers.

String - a string of zero or more Unicode characters. Strings are delimited by double quotes and support the backslash as an escape character.

Boolean - one of the values true or false, corresponding to the logical values true and false.

Array - an ordered list of zero or more values, each of which can be of any type. Arrays are delimited by square brackets, inside which are the values, also known as elements, separated by commas. The first element is index 0.

Object - an unordered collection of attribute-value pairs where the attributes (or names or keys) are strings. As objects are intended to represent associative arrays, it is recommended, but not required, that each attribute be unique within an object. Objects are delimited by curly braces and use commas to separate each pair, while in the pair the attribute and value are separated by a colon.

Null - Empty or null value represented by the word null.

Whitespace is allowed with bounds and ignored around and between syntactic elements, but not within a string. Only four characters are treated like this: space, horizontal tab, line feed, and carriage return. In particular, the byte order mark must not appear in a JSON document as per the standard.

JSON doesn't have a syntax for comments. To exchange data in an open ecosystem, JSON must be encoded in UTF-8.


Do you like our content? So, follow us on social media to stay on top of innovation and read our blog.
Share this article on your social networks:
Rate this article:
[yasr_visitor_votes size=”medium”]

CONTENT

Our Latest Articles
Read about the latest trends in technology
Blog 09-07
VR and AR are redefining multiple industries, offering immersive experiences ranging from...
Thumbnail Unlocking LATAM
The demand for tech talent in the USA and Europe keeps surging,...
Blog 04-07
Competitive programming is an excellent tool for developing essential soft skills in...

Extra, extra!

Assine nossa newsletter

Fique sempre atualizado com as novidades em tecnologia, transformação digital, mercado de trabalho e oportunidades de carreira

Would you like to speak with a Sales Representative?

Interested in: