JSON (JavaScript Object Notation) is a format used to serialize or organize data. Its main characteristic is its simplicity, resulting in lighter data files. Therefore, JSON is the standardized structure for organizing data objects that require interaction between servers or information storage, ahead of other more sophisticated and resource-intensive options such as XML.

JSON Structure

The JSON format consists of two pairs of curly braces {} and [] that contain the structure where each attribute and non-numeric value is entered in quotation marks { “attribute”: “value” } , separated by commas to group more attributes and values { “attribute”: “value”, “attribute” : “value”, “attribute: “value” }. Depending on the complexity of the object to be encoded, the structure may (or may not) contain values.

How to apply JSON format to an “object”?

To apply JSON format to an object, it is necessary to organize the content so that each attribute has values, whether they are null, strings, integers, or arrays. For example, if the object has the following data: User 1 First Name: Pedro Last Name: Pérez Username: Pedrope Age: 18 Country: Chile In format In JSON, we should enter:

{

\"user1\":

{

\"name:pedro\",

\"surname:perez\",

\"user:pedrope\",

\"age\":18,

\"country:chile\"

}
}
If you need to add more objects (another user in this case), simply add another structure separated by commas:

{

\"user1\":{

\"name:pedro\",

\"surname:perez\",

\"user:pedrope\",

\"age\":18,

\"country:chile\"

},

\"user2\":{

\"name:juan\",

\"surname:gonzalez\",

\"user:juangonza\",

\"age\":20,

\"country:argentina\"

}
}
The values in our JSON structure can also be arrays, defined using square brackets [ ]:
[1,2,3,4,5,6]

Conclusions

The JSON format is ideal for exchanging data quickly and effectively between servers due to its lightweight nature. If we take the example presented above and present it in XML format, we can better appreciate the character synthesis required by the JSON format:





18
perez
chile

pedro 
pedrope 
 
 
20 
gonzalez 
argentina 
juan 
juangonza 
 
 
 
 
Of course, the more data that needs to be shared, the more valuable this feature becomes. Despite the efficiency of JSON when working with data Although structured, there are still private and state institutions, such as the Internal Revenue Service, that continue to use XML through their developer APIs.