Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Go 迭代和更新map[string]接口{}的值的属性_Go_Go Interface_Go Map - Fatal编程技术网

Go 迭代和更新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

我们有一个界面对象,如下所示,数据如下所示

[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]接口{},但是当我们这样做时,结构与映射嵌套在一起。迭代接口对象中的所有属性的最佳方法是什么

//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指针库,例如:类型交换机。