I have two json files that I unmarshal in Go.
The first one includes a certain type of object that is referenced by ID in the second set.
// Foo
{
"id": 5,
"key": "value"
}
and
// Bar
{
"name": "bar",
"fooReferenceId": 5
}
I want to end up with a struct
like
type Bar struct {
Name string
Foo *Foo
}
Is there a way to achieve this directly similar to how we provide json:"..."
key resolver?
Something like
type Bar struct {
Name string `json:"name"`
Foo *Foo resolveFooById(`json:"fooReferenceId"`)
}