Skip to content

Commit

Permalink
Merge pull request #89 from francoispqt/doc/clean-up
Browse files Browse the repository at this point in the history
Clean doc and reorganise code
  • Loading branch information
francoispqt authored Oct 29, 2018
2 parents 346ac0d + a883d83 commit 3ebfcfb
Show file tree
Hide file tree
Showing 23 changed files with 1,109 additions and 838 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,21 @@ func (dec *gojay.Decoder) DecodeBool(v *bool) error
func (dec *gojay.Decoder) DecodeString(v *string) error
```

All DecodeXxx methods are used to decode top level JSON values. If you are decoding keys or items of a JSON object or array, don't use the Decode methods.

Example:
```go
reader := strings.NewReader(`"John Doe"`)
dec := NewDecoder(reader)

var str string
err := dec.DecodeString(&str)
if err != nil {
log.Fatal(err)
}

fmt.Println(str) // gojay
```

### Structs and Maps
#### UnmarshalerJSONObject Interface
Expand Down Expand Up @@ -287,6 +302,28 @@ func main() {
}
```

### Decode values methods
When decoding a JSON object of a JSON array using `UnmarshalerJSONObject` or `UnmarshalerJSONArray` interface, the `gojay.Decoder` provides dozens of methods to Decode multiple types.

Non exhaustive list of methods available (to see all methods, check the godoc):
```go
dec.Int
dec.Int8
dec.Int16
dec.Int32
dec.Int64
dec.Uint8
dec.Uint16
dec.Uint32
dec.Uint64
dec.String
dec.Time
dec.Bool
dec.SQLNullString
dec.SQLNullInt64
```


## Encoding

Encoding is done through two different API similar to standard `encoding/json`:
Expand Down
Loading

0 comments on commit 3ebfcfb

Please sign in to comment.