我们有一个如下所示的接口对象,数据如下所示
[地图[com.org.exts.criteria.model.Sourceemployee:map[active:true ids:map[com.org.exts.criteria.model.employee.ids:map[alternateIds:alternateSubId:map[string:SomeValuestring] IDnumber: somefiledAssignedIds: familyId:map[int:111] MyAccountIds: ABCNumbers: OldIds: nrtNumbers: GHTNumb: Somefiledx: Somefiledx: Somefiledz:map[string:OldId1] somefiled779: someIds: somenumberfiled: someoriginid: someconsumerids:]
我可以将接口转换为 map[string]interface{},但是当我们这样做时,结构会嵌套在地图中。遍历接口对象中的所有属性最好的方法是什么?
//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]interface{},但无法动态导航与地图嵌套。尝试动态遍历地图中的每个属性并能够对其进行更新。