Go 迭代和更新map[string]接口{}的值的属性
我们有一个界面对象,如下所示,数据如下所示 [map[com.org.exts.criteria.model.Sourceemployee:map[active:true-ids:map[com.org.exts.criteria.model.employee.ids:map[alternateIds:alternateSubId:map[string:SomeValuestring]ids:familyId:map[int:111]MyAccountId:ABCNumbers:oldID:nNumber:GHTNumb:Somefiledx:Somefiledx:Somefiledz:map[string:OldId1]somefiled779:SomeId:SomeNumber文件:someoriginid:someconsumerids:] 我可以将接口转换为map[string]接口{},但是当我们这样做时,结构与映射嵌套在一起。迭代接口对象中的所有属性的最佳方法是什么Go 迭代和更新map[string]接口{}的值的属性,go,go-interface,go-map,Go,Go Interface,Go Map,我们有一个界面对象,如下所示,数据如下所示 [map[com.org.exts.criteria.model.Sourceemployee:map[active:true-ids:map[com.org.exts.criteria.model.employee.ids:map[alternateIds:alternateSubId:map[string:SomeValuestring]ids:familyId:map[int:111]MyAccountId:ABCNumbers:oldID:nN
//My code looks below.
func (m *DataMapping) Map(rowMap *Datamapper.RowMap, previousRowValue map[string]interface{}) (buffer bytes.Buffer, err error) {
for stageKey := range previousRowValue {
stageKeyValueData := previousStageValue[stageKey]
// Some code for iterating through the map here is the challenge
}
}
我们可以将接口作为一个MAP[String ]接口{},如上面代码中所提到的,但是不能动态地嵌套在地图中。尝试动态遍历地图中的每个属性并能够更新它。
请考虑使您的问题可读。您可能想尝试一个JSON指针库,例如:类型交换机。