Getting started with JSON
JSON is the most used format to communicate data among applications, such as HTTP APIs or web applications. The other formats of data include XML, CSV, TSV, and text files, to mention a few.
For the sake of demonstration, consider the following Note
struct:
struct Note { id int message string status bool }
We can represent this Note
struct in JSON format as follows:
{ "id": 1, "message": "Plan a holiday", "status": false }
The representation of a JSON object in the preceding code is easy to read and understand:
- A JSON object typically starts with
{
(an opening curly bracket) and ends with}
(a closing curly bracket). - A JSON object has various properties represented as key-value pairs separated by a
:
(colon...