DATA STRUCTURES: JSON

Working with JSON in Go

JSON is a text-based data exchange format primarily used between browsers and servers. In this article, we are going to look at JSON encoding and decoding APIs provided by the Go.

Uday Hiwarale
RunGo
Published in
22 min readMar 1, 2020

--

(source: unsplash.com)

JSON (JavaScript Object Notation) is one of the most popular data exchange formats on the web. It’s a text encoded format, which means JSON data is a string of characters written in valid JSON format. You can follow the format of JSON from RFC 7159 documentation.

The example below is a valid JSON format, however, you may need to convert this text-data into a string data-type first in order to work with JSON APIs provided by the language.

{
"firstName": "John",
"lastName": "Doe",
"age": 21,
"heightInMeters": 1.75,
"isMale": true,
"profile": null,
"languages": [ "English", "French" ],
"grades": {
"math": "A",
"science": "A+"
}
}

The JSON format was created as a means to transport data between browser and server that can be easily encoded from a JavaScript object or decoded to a JavaScript object by the JavaScript engine. Hence, JSON data looks exactly like a JavaScript object but in a string format.

--

--