1
0
mirror of https://github.com/json-iterator/go.git synced 2025-04-26 11:42:56 +02:00
json-iterator/jsoniter_demo_test.go

24 lines
348 B
Go
Raw Normal View History

2016-12-11 15:53:35 +08:00
package jsoniter
import (
"fmt"
"testing"
2016-12-11 15:53:35 +08:00
)
func Test_bind_api_demo(t *testing.T) {
iter := ParseString(`[0,1,2,3]`)
val := []int{}
2017-01-09 17:47:21 +08:00
iter.ReadVal(&val)
2016-12-11 15:53:35 +08:00
fmt.Println(val[3])
}
func Test_iterator_api_demo(t *testing.T) {
iter := ParseString(`[0,1,2,3]`)
total := 0
for iter.ReadArray() {
total += iter.ReadInt()
}
fmt.Println(total)
}