更新后的json如下:
{
"phone":[
{"home":"58878767"},
{"mobile":"32453543"}
],
"org": [
{
"current": {
"org_dept": "Hr",
"org_eptime": "1516354574432",
"org_name": "Uejsjak",
"org_title": "Hakosklaks"
}
},
{
"current": {
"org_dept": "Accounts",
"org_eptime": "1516354561184",
"org_name": "Abcd",
"org_title": "Hakahkshsjs"
},
{
"past": {
"org_dept": "Backend",
"org_eptime": "15163545",
"org_name": "Ab",
"org_title": "Hakah"
}
}
]
}
我正在使用以下代码在键和值上打印:
personMap := make(map[string][]map[string]string)
json.Unmarshal([]byte(ii), &personMap)
for key, value := range personMap {
fmt.Println("index : ", key, " value : ", value){
}
我得到的输出是:
index: org value: [map["current":""],map["current":""]
我如何打印字段“当前”下的每个字段值??????
现在我正在这样做:
personMap := make(map[string][]struct{Current map[string]string})
json.Unmarshal([]byte(ii), &personMap)
for key, value := range personMap {
fmt.Println("index : ", key, " value : ", value)
}
我得到的输出是:
index : org value : [{map[org_dept:Hr org_eptime:1516354574432 org_name:Uejsjak org_title:Hakosklaks]} {map[org_dept:Accounts org_eptime:1516354561184 org_name:Abcd org_title:Hakahkshsjs]}]
index : phone value : [{map[]} {map[]}]