Services:
- Orders:
- ID: $save ID1
SupplierOrderCode: $SupplierOrderCode
- ID: $save ID2
SupplierOrderCode: 111111
Run Code Online (Sandbox Code Playgroud)
我想将这个yaml字符串转换为json,因为源数据是动态的,所以我无法将它映射到结构:
var body interface{}
err := yaml.Unmarshal([]byte(s), &body)
Run Code Online (Sandbox Code Playgroud)
然后我想再次将该接口转换为json字符串:
b, _ := json.Marshal(body)
Run Code Online (Sandbox Code Playgroud)
但是会发生错误:
panic: json: unsupported type: map[interface {}]interface {}
Run Code Online (Sandbox Code Playgroud)