Hello,
When using the json encoder, you probably know that you can write this:
type Object struct {
Field int32 `json:"externalField"`
}
And when (de)serialized, the json package will use the name "externalField" instead of "Field".
For example, it will parse/generate the following json:
{ "externalField": 123 }
However, what about when two fields are declared on the same line, such as:
type Point struct {
X, Y, Z int32
}
Is it possible to use tags in that case ? The spec says that the tag "becomes an attribute for all the fields in the corresponding field declaration."
Which means that X, Y and Z will get the same tag.
I tried to specify different json tags like this:
type Point struct {
X, Y, Z int32 `json:"x",json:"y",json:"z"`
}
but it didn't work.
I am guessing the json package doesn't even get the information that field Y, with the tag `json:"x",json:"y",json:"z"`, was the second in a list of fields.
Bug ? Feature ? Me being silly (could be... I mean, at this point, I should just break the declaration in multiple lines as it would be more clear... but curiosity :) ) ?
Thanks.