With json objects it's simple:
type MyObj struct {
Prop1 int `json:"prop1"`
Prop2 []string `json:"prop2"`
}
How would I cast simple []string
slice against MyObj? I know I could iterate over slice and manually assign each property by respective index, but maybe there's more optimal way, considering that Prop1 references at 0 index of the slice, and Prop2 - 1.
EDIT1:
My actual JSON string looks like [100, 200]
. So MyObj.Prop1
would get filled with 100
, and MyObj.Prop2
with 200
respectively.
Thank you.