Go 的 JSON 开发包 Jason
- 授权协议: MIT
- 开发语言: Google Go
- 操作系统: 跨平台
- 软件首页: https://github.com/antonholmquist/jason
- 软件文档: https://godoc.org/github.com/antonholmquist/jason
软件介绍
Jason 是一个 Go 语言用来处理 JSON 文档的开发包。Jason 的强项是解析 JSON 而不是生成 JSON。
示例代码:
root, err := jason.NewFromReader(res.Body)
root.Get("name").String()
root.Get("age").Number()
root.Get("verified").Boolean()
root.Get("education").Object()
root.Get("friends").Array()
//读取嵌套内容
root.Get("person", "name").String()
root.Get("person", "age").Number()
root.Get("person", "verified").Boolean()
root.Get("person", "education").Object()
root.Get("person", "friends").Array()
//判断数值是否存在
root.Has("person", "name")
root.Get("person", "name").Exists()
//数值校验
root.Get("name").IsString()
root.Get("age").IsNumber()
root.Get("verified").IsBoolean()
root.Get("education").IsObject()
root.Get("friends").IsArray()
root.Get("friends").IsNull()
//循环
for _, friend := range person.Get("friends").Array() {
name := friend.Get("name").String()
age := friend.Get("age").Number()
}完整例子:
package main
import (
"github.com/antonholmquist/jason"
"log"
)
func main() {
exampleJSON := `{
"name": "Walter White",
"age": 51,
"children": [
"junior",
"holly"
],
"other": {
"occupation": "chemist",
"years": 23
}
}j, _ := jason.NewObjectFromBytes([]byte(exampleJSON)) log.Println("name:", j.Get("name").String())
log.Println("age:", j.Get("age").Number())
log.Println("occupation:", j.Get("other", "occupation").String())
log.Println("years:", j.Get("other", "years").Number())
for i, child := range j.Get("children").Array() {
log.Printf("child %d: %s", i, child.String())
}
}
赢在设计
[美] 洛芙迪 (Lance Loveday)、[美] 尼豪斯 (Sandra Niehaus) / 刘淼、枊靖、王卓昊 / 人民邮电出版社 / 2010-8 / 55.00
企业总是面临在网站设计和改进方面进行投资的抉择。怎样才能让有限的资金发挥出最大的效益呢?网站设计不应只是把网站做得赏心悦目,它更应该是提高经济收益和获得竞争优势的战略利器。是时候让网站发挥其潜能,以业务指标为导向来做设计决策,为提升网站收益而设计了。 作者凭借多年为众多网站做咨询工作的经验,为我们揭示了赢在设计的奥秘。它针对目前网站设计中存在的典型问题,先从宏观上探讨解决问题的战略手段,围绕......一起来看看 《赢在设计》 这本书的介绍吧!
