var a interface{}
a = xxStruct{}
json.Unmarshal(jsonData,&a)
The "a" become to be a map, not a struct. For java, I could do it like this:
Object obj = new XXObject();
String json = JSON.toJSONString(obj);
obj = JSON.parse(json,obj.getClass())
//and also I can convert obj to original object.
//but How do this in "go"?
XXObject x = (XXObject)obj;
x.xxxSet(); //call method as normal.
I try using reflect.ValueOf(), reflect.TypeOf() and type convert like v:=a.(XXStruct) etc. but it doesn't work, What should I do?
Declare a
as a variable of type xxStruct, not interface{}:
var a xxStruct