What is Json?
The scope of software and processed information is increasing rapidly day by day. However, it has become almost normal for software to communicate with each other.
Therefore, it is important for programmers to have their own data structures in a format that can be recognized and read by other languages and platforms from the language in which it is written.
We can think of this as using your mother tongue in your own business, but knowing and using English to communicate with the outside world.
What is JSON?
JSON is short for JavaScript Object Notation. It is a performant, language-independent form of standardization for storing and manipulating data.
It was created to make it easy to store, send and read data across all programming languages.
JSON is used to facilitate data transfer between a client and a server.
When there is a data flow from client to server or from server to client, the data is converted into JSON format and sent to the other party in this way. Thus, even if the two units are written in different languages, since both recognize the JSON format, communication between them will be provided without any problems.
{
“name” : “Jale”,
“surname” : “Lightning”,
“age” : 27,
“student” : true,
“lessons” : [“Math”, “Economics”, “French”]
}
What are JSON Properties?
The most basic features of the JSON format are shown below.
- JSON, data is stored in colon-separated name:value (name:value) pairs.
- Names must be enclosed in double quotes ("").
- Each name:value pair is separated from the other by a comma.
- The curly braces hold objects. {"name": value}
- Square brackets hold strings. []
What are JSON Data Types?
JSON data types are divided into 6 . These are string, number, boolean, object, array and null.
Example of String (text) data type..
Values ??must be written in double quotes.
{ "name" : "Zeynep" }
Example of Number (number) data type..
Values ??must be written without double quotes. Represents whole and fractional numbers. Fractions are written with dots.
{ "age" : 21 }
{ "average" : 52.75}
Example of Boolean (true-false) data type..
It only accepts true or false without double quotes.
{ "degree" : false }
Example of Object (object) data type..
It is a set of name:value pairs inserted between the curly brackets "{}". Each set must be unique. Multiple sets must be separated by commas.
{
"Student" : { "name" : "Zeynep", "age" : 21, "average" : 52.55, "degree" : false }
}
Example of Array (array) data type..
Square brackets are a set of array elements enclosed in "[]". Each element must be separated by commas.
{
"cities" : [ "London", "Sydney", "Paris", "Rome", "Miami" ]
}
Example of Array (array) data type - 2
{
"students" : [ {"name" : "Zeynep"}, {"name" : "Ali"}, {"name" : "Joe"} ]
}
Example of Null data type..
Only "null" is defined. Null means it has no value.
{
"exam2Result" : null
}