You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-21 23:07:33 +02:00
implement any api
This commit is contained in:
27
jsoniter_any_test.go
Normal file
27
jsoniter_any_test.go
Normal file
@ -0,0 +1,27 @@
|
||||
package jsoniter
|
||||
|
||||
import "testing"
|
||||
|
||||
func Test_read_string_as_any(t *testing.T) {
|
||||
iter := ParseString(`[1, {"hello": "world"}, 2]`)
|
||||
any := iter.ReadAny()
|
||||
if any.GetString(1, "hello") != "world" {
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
func Test_read_float64_as_any(t *testing.T) {
|
||||
iter := ParseString(`1.23`)
|
||||
any := iter.ReadAny()
|
||||
if any.GetFloat32() != 1.23 {
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
func Test_read_int_as_any(t *testing.T) {
|
||||
iter := ParseString(`123`)
|
||||
any := iter.ReadAny()
|
||||
if any.GetFloat32() != 123 {
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user