First commit of most of the pages laid out for the next phase.
This commit is contained in:
parent
b9f811f1b5
commit
f0dd939acd
16 changed files with 2601 additions and 0 deletions
28
scratchpad/json_decode.go
Normal file
28
scratchpad/json_decode.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
b, err := os.ReadFile("user.json")
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to read file: %v\n", err);
|
||||
}
|
||||
|
||||
var u User
|
||||
json.NewDecoder(bytes.NewBuffer(b)).Decode(&u)
|
||||
|
||||
fmt.Printf("%#v", u)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue