commit a883d839e3ac97099a858709602b2cd2e44573a7
parent f1707a9a3f739110209d773e41bcb287c97591fc
Author: francoispqt <francois@parquet.ninja>
Date: Mon, 29 Oct 2018 22:27:22 +0800
update README
Diffstat:
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
@@ -174,6 +174,20 @@ 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
@@ -288,7 +302,7 @@ func main() {
}
```
-#### Decode values methods
+### 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):