https://github.com/seefan/jsonreader
json reader
https://github.com/seefan/jsonreader
go golang json jsonreader
Last synced: about 1 month ago
JSON representation
json reader
- Host: GitHub
- URL: https://github.com/seefan/jsonreader
- Owner: seefan
- License: mit
- Created: 2019-03-26T08:34:08.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-09T02:37:10.000Z (over 6 years ago)
- Last Synced: 2024-06-20T06:36:46.709Z (over 1 year ago)
- Topics: go, golang, json, jsonreader
- Language: Go
- Size: 98.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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)
})