<分区>
我想使用 Golang 将我的 map 数据放入另一个 map 数据。但是它有结构类型。
这是我的代码。
birth := make(map[string]interface{})
birth["docType"] = "registerBirth"
birth["agencyCd"] = string(args[0])
birth["birthYmd"] = string(args[1])
birth["lsTypeNm"] = string(args[2])
birth["monthDiff"] = string(args[3])
birth["nationNm"] = string(args[4])
birth["sexNm"] = string(args[5])
birth["regType"] = string(args[9])
birth["regYmd"] = string(args[10])
我想把这个 map 数据放到另一个 map 上,但是我想使用struct类型。
cattle := make(map[string]interface{})
cattle["docType"] = "information"
cattle["birthInfo"] = struct {
birth map[string]interface{}
}{
birth,
}
但是,当我得到数据时..结果是这样的。
{"birthInfo":{},"docType":"information"}
这是我想要的例子。
"birthInfo": {
"birthYmd": "2018-07-25",
"cattleNo": "cow001",
"docType": "registerBirth",
"farmNo": "farm001",
"flatEartagNo": "eartag123123",
"lsTypeNm": "황소",
"monthDiff": "2018-07",
"nationNm": "austria",
"regType": "직접",
"regYmd": "20185-07-25",
"sexNm": "M"
},
"docType": "information",
...
提前致谢。