在线json转golang结构定义代码工具
package main
import (
"encoding/json"
"fmt"
)
type MyStructName struct {
Description string `json:"description"`
Name string `json:"name"`
}
func main() {
jsonSrc := []byte(`{
"name": "abc",
"description": "def"
}`)
var m MyStructName
json.Unmarshal(jsonSrc, &m)
if m.Description == "def" {
fmt.Println("ok")
}
}