August 2019
Beginner to intermediate
798 pages
17h 2m
English
In this subsection, you will see how to use the Marshal() and Unmarshal() methods in order to implement the functionality of readJSON.go and writeJSON.go. The Go code that illustrates the Marshal() and Unmarshal() functions can be found in mUJSON.go, and it will be presented in three parts.
The first part of mUJSON.go is as follows:
package main
import (
"encoding/json"
"fmt"
)
type Record struct {
Name string
Surname string
Tel []Telephone
}
type Telephone struct {
Mobile bool
Number string
}
In this part of the program, we are defining two structures named Record and Telephone, which will be used for storing the data that will be put into a JSON record.
The second part of mUJSON.go is as follows:
func main() ...
Read now
Unlock full access