1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-21 23:07:33 +02:00

make any easier to work with

This commit is contained in:
Tao Wen
2016-12-11 10:04:26 +08:00
parent e427475e9c
commit 2895fe2215
6 changed files with 188 additions and 64 deletions

View File

@ -5,7 +5,7 @@ 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" {
if any.ToString(1, "hello") != "world" {
t.FailNow()
}
}
@ -13,7 +13,7 @@ func Test_read_string_as_any(t *testing.T) {
func Test_read_float64_as_any(t *testing.T) {
iter := ParseString(`1.23`)
any := iter.ReadAny()
if any.GetFloat32() != 1.23 {
if any.ToFloat32() != 1.23 {
t.FailNow()
}
}
@ -21,7 +21,7 @@ func Test_read_float64_as_any(t *testing.T) {
func Test_read_int_as_any(t *testing.T) {
iter := ParseString(`123`)
any := iter.ReadAny()
if any.GetFloat32() != 123 {
if any.ToFloat32() != 123 {
t.FailNow()
}
}