Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
glossd committed Oct 20, 2024
1 parent 9c06542 commit bd29b63
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ To convert `fetch.J` to a basic value use one of `As*` methods
| AsNumber | float64 |
| AsString | string |
| AsBoolean | bool |

E.g.
```go
j, err := fetch.Unmarshal[fetch.J](`{"price": 14.99}`)
Expand All @@ -219,11 +220,15 @@ fmt.Printf("Price: %f\n", n) // n is a float64
```go
j, err := fetch.Unmarshal[fetch.J]("{}")
if err != nil {
panic(err)
panic(err)
}
if j.Q(".price").IsNil() {
// key 'price' doesn't exist
}
// fields of unknown values are nil as well.
if j.Q(".price.cents").IsNil() {
fmt.Println("'cents' of undefined is fine.")
}
```

### JSON handling
Expand Down

0 comments on commit bd29b63

Please sign in to comment.