Suppose I have a struct Foo
.
Foo struct {
Bar, Baz int
}
And I want to marshal this struct into json
like so:
{bar : 1, baz : 2}
How could I achieve that, without splitting my single line multiple name declaration (Bar, Baz int
) into 2 separate lines using tags.
This works:
Foo struct { Bar int `json:"bar"` Baz int `json:"baz"` }
But I'd like:
Foo struct { Bar, Baz int `json:???` }
Is the latter even possible?