Sfoglia il codice sorgente

Merge pull request #49 from zhaitianduo/master

Use jsoniter instead of json in example
Tao Wen 8 anni fa
parent
commit
4f909776cf
1 ha cambiato i file con 7 aggiunte e 7 eliminazioni
  1. 7 7
      example_test.go

+ 7 - 7
example_test.go

@@ -2,9 +2,9 @@ package jsoniter_test
 
 import (
 	"fmt"
-	"github.com/json-iterator/go"
 	"os"
-	"encoding/json"
+
+	"github.com/json-iterator/go"
 )
 
 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}]
-}
+}