JSON in Go: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 7: Line 7:


=JSON Marshalling Go → JSON=
=JSON Marshalling Go → JSON=
JSON marshalling means generating a JSON representation from a Go object.
JSON marshalling means generating a JSON representation from a Go object. It is done with <code>json.Marshal()</code>. The result is a byte array. To convert the byte array to a string, see: {{Internal|Go_Integers#Conversion_between_bytes_and_strings|Go Integers &#124; Conversion between bytes and strings}}


==Map Marshalling==
==Map Marshalling==
==Struct Marshalling==
==Struct Marshalling==
By default, only fields that start with capital letters are marshaled. The fields that start with lower caps are invisible to the marshaling process.
By default, only fields that start with capital letters are marshaled. The fields that start with lower caps are invisible to the marshaling process.
Also see: {{Internal|Go_Integers#Conversion_between_bytes_and_strings|Go Integers &#124; Conversion between bytes and strings}}
<font color=darkkhaki>TO PROCESS: https://golang.cafe/blog/golang-json-marshal-example.html</font>
<font color=darkkhaki>TO PROCESS: https://golang.cafe/blog/golang-json-marshal-example.html</font>


=JSON Unmarshalling JSON → Go=
=JSON Unmarshalling JSON → Go=

Revision as of 17:08, 25 August 2023

Internal

Overview

JSON Marshalling Go → JSON

JSON marshalling means generating a JSON representation from a Go object. It is done with json.Marshal(). The result is a byte array. To convert the byte array to a string, see:

Go Integers | Conversion between bytes and strings

Map Marshalling

Struct Marshalling

By default, only fields that start with capital letters are marshaled. The fields that start with lower caps are invisible to the marshaling process. TO PROCESS: https://golang.cafe/blog/golang-json-marshal-example.html

JSON Unmarshalling JSON → Go