JSONAPI.org 为 Go 语言的实现
对于完整的 api2go 包,请使用:```go go get github.com/manyminds/api2go
如果只需要序列化和/或反序列化:```
go get github.com/manyminds/api2go/jsonapi Api2go 会与 Go 内部的 json 包完全相同地进行序列化和反序列化,但有一个附加功能:它会为序列化的 JSON 添加 jsonapi 元对象。Jsonapi 将有效载荷包装到一个 attributes 对象中。其余部分只是元数据,将由 api2go 生成。因此,让我们来看看这个基本示例:```go
type Article struct {
ID string
Title string json:"title"
}
对于 api2go,您必须忽略标记 `ID` 字段,然后结果可能如下所示:
```json
{
"type": "articles",
"id": "1",
"属性": {
"title": "Rails 是 Omakase"
}
"关系": {
"author": {
"links": {
"self": "/articles/1/relati暂无开放 Issues,或尚未同步最近议题。