JSON Documentation Team Cambodia

From Coder Merlin
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder


Jsons-Deli.png

What is JSON?[edit]

JSON is a lightweight method of storing, sending, and retrieving data. It stands for JavaScript Object Notation. It is often used to send data from a server to a web page.

JSON is language-independent, therefore it is a great data interchanging format. Useful for talking between computers/servers. REST API uses JSON to talk between the server and the client conveniently.

It is based on two integral structures:

  1. A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
  2. An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

Because these structures are universal to any coding language, it enables JSON to be effective at data formatting.

JSON Syntax Rules[edit]

There are 4 main rules for JSON Syntax:

  • Data is in pairs of name/value
  • Data is separated by commas
  • Curly braces contain objects
  • Square brackets contain arrays

JSON Text File Example[edit]

{
“Students”: [
	{“firstName”:”John”, “lastName”:”Williams”}
	{“firstName”:”Tony”, “lastName”:”Stark”}
	{“firstName”:”Barry”, “lastName”:”Allen”}
    {“firstName”:”David”, “lastName”:”Ben-Yaakov”}
]
}

Sources[edit]

https://www.w3schools.com/whatis/whatis_json.asp

https://www.json.org/json-en.html

https://stackoverflow.blog/2020/03/02/best-practices-for-rest-api-design/

https://docs.python.org/3/library/json.html