Skip to content

Commit

Permalink
fix minor mistake in README
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaeguard committed Oct 30, 2023
1 parent 958ae25 commit 0197795
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ type WebConfig struct {
}

func main() {
json, err := gojson.ParseJson(
`{
inputJson := `{
"Hostname": "localhost",
"Port": 8282,
"IsActive": true
}`,
)
}`
json, err := gojson.Parse(inputJson)

if err != nil {
// error occurred
Expand All @@ -48,6 +47,13 @@ func main() {
} else {
fmt.Printf("%-v\n", wc.Port)
}

// we can unmarshall in one step as well
if uerr := gojson.Unmarshal(inputJson, &wc); uerr != nil {
// error occurred
} else {
fmt.Printf("%-v\n", wc.Port)
}
}

```

0 comments on commit 0197795

Please sign in to comment.