这是Go playground链接.
基本上'\u0000'我的JSON字符串键中有一些特殊字符():
var j = []byte(`{"Page":1,"Fruits":["5","6"],"\u0000*\u0000_errorMessages":{"x":"123"},"*_successMessages":{"ok":"hi"}}`)
Run Code Online (Sandbox Code Playgroud)
我想将它解组成一个结构:
type Response1 struct {
Page int
Fruits []string
Msg interface{} `json:"*_errorMessages"`
Msg1 interface{} `json:"\\u0000*\\u0000_errorMessages"`
Msg2 interface{} `json:"\u0000*\u0000_errorMessages"`
Msg3 interface{} `json:"\0*\0_errorMessages"`
Msg4 interface{} `json:"\\0*\\0_errorMessages"`
Msg5 interface{} `json:"\x00*\x00_errorMessages"`
Msg6 interface{} `json:"\\x00*\\x00_errorMessages"`
SMsg interface{} `json:"*_successMessages"`
}
Run Code Online (Sandbox Code Playgroud)
我尝试了很多,但它没有用.此链接可能有助于golang.org/src/encoding/json/encode_test.go.
这是我的示例:http : //play.golang.org/p/D608cYqtO5
基本上我想这样做:
theType := reflect.TypeOf(anInterfaceValue)
theConvertedValue := anInterfaceValue.(theType)
Run Code Online (Sandbox Code Playgroud)