programming

01 Introduction Package

Introduction to JSON

JSON stands for JavaScript Object Notation which is a data format structure that looks like Object from JavaScript. JSON is the most widely used data format currently for creating RESTful APIs. All languages can use the JSON format because it can become a standard format for communication between services even if they use different languages. For example, one service uses Golang and another service uses Java, so that it can communicate well it needs the same format, namely JSON, which can standardize the format of the two languages in our service. You can visit https://json.org/json-en.html if you want to learn more.

The following is an example of JSON format

{
	"first_name": "Ihsan",
	"middle_name": "Arif",
	"last_name": "Rahman",
	"website": {
		"title": "Berbagi Ilmu dan Informasi Tentang Teknologi",
		"url": "https://www.santekno.com"
	},
	"hobbies": [
		"coding",
		"badminton",
		"reading"
	]
}

In the Golang programming language, a JSON package is available which we can use this package for our needs to convert data to JSON (encode) or vice versa from JSON into struct data that can be read by Golang (decode). For more details, we can see this JSON package at the link https://pkg.go.dev/encoding/json.

Object JSON Format.

JSON Object Visualization

We can see above that the JSON object format starts with an open brace { and ends with a closed brace }. Between the two braces, the contents of a string are inserted which are filled with keys and values which we will display with various colons.

JSON Array format

JSON Array Visualization

The JSON array format starts with an open angle [ then the value ends with a comma , and closes with a closed angle ]

JSON Value Format

JSON Value Visualization

In fact, almost all of the value formats supported by JSON can be supported, for example strings, numbers, objects, arrays, boolans, or null.

comments powered by Disqus