Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
seefan committed Apr 18, 2019
1 parent 7c054a1 commit e42b75c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
# jsonreader
json reader

obj := ParseJsonObject([]byte("{\"contacts\":{ \"company\":{ \"address\":null, \"state_code\":null }, \"employees\":[ null] }}"))
v := obj.V("contacts").ParseJsonObject().A("employees")
if v.Size() == 0 {
t.Error(" parse error")
} else {
t.Log(v.Get(0).String(), v.Get(0).IsNull())
}


arr := ParseJsonArray([]byte("[{\"data\" : {\"key\" : 123,\"abc\":-1021e5 } , \"value\":5 ,\"ars\":[1,2,3,4,{\"value\":5},\"6\",{\"value\":7}]},0,1,\"sfdada\"]"))
arr.Each(func(i int, value JsonValue) {
if i == 0 {
key := value.ParseJsonObject().GetObject("data").GetValue("key")
if key != "123" {
t.Error("get key value!=123")
}
}
t.Log(i, value)
})

0 comments on commit e42b75c

Please sign in to comment.