#Object

4 articles

06 How to know JSON Tags

06 How to know JSON Tags

Introduction to JSON Tags

By default, if we create a struct and marshal it, it will be mapped according to the same attribute name and is case sensitive. So what if we want to differentiate the style between naming attributes in structs and those converted into JSON? For example, in structs we use PascalCase but in JSON we want to use snake_case. To support this, the json package supports Tags Reflection, namely tags that can adjust the Json name which we will later convert into JSON so that the tribute in the struct will be converted according to the name into JSON.

05 How to know JSON Array

05 How to know JSON Array

Introduction to JSON Arrays

Apart from JSON in Object form, usually in JSON we can also use the Array data type. Actually, JSON arrays are similar to those in JavaScript where there are primitive data types or complex data types such as object arrays.

04 How to know Decode JSON

04 How to know Decode JSON

Introduction to JSON Decoding

In the previous article we learned to encode JSON and how to create a JSON object, so next we will learn how to translate JSON objects into struct objects in Golang. We often call this conversion from JSON into a Golang struct object as decode.

03 How to know JSON Object

03 How to know JSON Object

Introduction to JSON Objects

In the previous article we studied encoding data such as string, number, boolean and other primitive types. But there is one case in the unit test which is made in the form of a struct object. So, this time we will study the objects of JSON in more depth. JSON data is in the form of objects and arrays, while the values can be objects again or directly data with other primitive types.