I have a struct as below:
type Item struct {
ID int16 `json:"id"`
SubItem *Item `json:"sub_item"`
}
And the JSON as below:
{
"id": 100,
"sub_item": 110
}
If I use json.Unmarshal(json, &item)
, the json field sub_item
is the Item.ID
, so cannot mapping into struct.
I want to find the SubItem by the subitem id before json unmarshal, but I don't know how to do it. Or is there any way to resolve this problem? thanks a lot.