dynamic-struct icon indicating copy to clipboard operation
dynamic-struct copied to clipboard

Can we assign a structure variable to a structure field

Open gaofeng-lin opened this issue 3 years ago • 0 comments

instance := dynamicstruct.NewStruct(). AddField("Integer", 0, json:"int"). AddField("Text", "", json:"someText"). AddField("Float", 0.0, json:"double"). AddField("Boolean", false, ""). AddField("Slice", []interface{}{}, ""). AddField("Anonymous", "", json:"-"`). Build(). New()

data := []byte(`

{ "int": 123, "someText": "example", "double": 123.45, "Boolean": true, "Slice": { "Test": 124, "Test2": 234 }, "Anonymous": "avoid to read" } ) The error message is as follows: json: cannot unmarshal object into Go struct field .Slice of type []interface {} exit status 1

gaofeng-lin avatar May 30 '22 09:05 gaofeng-lin