1
0
mirror of https://github.com/json-iterator/go.git synced 2025-02-01 19:14:29 +02:00

use jsoniter for example

This commit is contained in:
zhaitianduo 2017-06-09 16:25:58 +08:00
parent 2608d40f2a
commit 46d443fbad

View File

@ -1,10 +1,10 @@
package jsoniter_test
import (
"encoding/json"
"fmt"
"github.com/json-iterator/go"
"os"
"encoding/json"
)
func ExampleMarshal() {
@ -33,15 +33,15 @@ func ExampleUnmarshal() {
{"Name": "Quoll", "Order": "Dasyuromorphia"}
]`)
type Animal struct {
Name string
Order string
Name string
Order string
}
var animals []Animal
err := json.Unmarshal(jsonBlob, &animals)
err := jsoniter.Unmarshal(jsonBlob, &animals)
if err != nil {
fmt.Println("error:", err)
fmt.Println("error:", err)
}
fmt.Printf("%+v", animals)
// Output:
// [{Name:Platypus Order:Monotremata} {Name:Quoll Order:Dasyuromorphia}]
}
}