1
0
mirror of https://github.com/json-iterator/go.git synced 2025-12-20 23:30:38 +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

@@ -15,3 +15,23 @@ func Test_read_map(t *testing.T) {
t.Fatal(m)
}
}
func Test_read_map_of_interface(t *testing.T) {
iter := ParseString(`{"hello": "world"}`)
m := map[string]interface{}{"1": "2"}
iter.Read(&m)
if !reflect.DeepEqual(map[string]interface{}{"1": "2", "hello": "world"}, m) {
fmt.Println(iter.Error)
t.Fatal(m)
}
}
func Test_read_map_of_any(t *testing.T) {
iter := ParseString(`{"hello": "world"}`)
m := map[string]Any{"1": any("2")}
iter.Read(&m)
if !reflect.DeepEqual(map[string]Any{"1": any("2"), "hello": any("world")}, m) {
fmt.Println(iter.Error)
t.Fatal(m)
}
}