JSON (JavaScript Object Notation) is a lightweight data exchange format that is easy for humans to read and write, and easy for machines to parse and generate. It is based on a subset of the JavaScript programming language, but is completely language-independent. JSON is widely used for data exchange between a server and a web application, mobile applications, and for data storage.
JSON is built on two basic structures:
A collection of "name/value" pairs: In many languages, this is implemented as an object, record, structure, dictionary, hash table, keyed list, or associative array. In JSON, this is represented by an object, denoted by curly braces {}
.
{
"name": "Ivan",
"age": 30,
"city": "Kyiv"
}
An ordered list of values: In most languages, this is implemented as an array, vector, list, or sequence. In JSON, this is represented by an array, denoted by square brackets []
.
[
"apple",
"banana",
"orange"
]
Values can be strings, numbers, objects, arrays, boolean values (true/false) or null.
JSON is an integral part of modern web development. Here are a few typical scenarios for its use:
Parameter | XML | JSON |
---|---|---|
Format | Text with tags | Text with keys and values |
Readability | Higher for complex structures | Better for simple data |
File size | Usually larger | Smaller |
Compatibility | Broad support | Mainly in JavaScript |
XML is better suited for complex structures with attributes, while JSON is for lightweight REST APIs.
Sometimes there is a need to convert data from a tabular format, for example, from Microsoft Excel, to JSON. This can be useful for importing data into web services or databases that work with JSON. Although Excel does not have a built-in function for direct export to JSON, there are third-party solutions.
One such useful tool is the custom Excel function TABLETOJSON(). This function allows you to easily convert data from an Excel table to a JSON string.