proposal: encoding/json: add "inline" struct tag #6213
Comments
I think this is worthwhile. I have an unfinished proposal in my email drafts that is basically exactly what Gustavo describes in his bson release announcement mail. It should be simple enough that it could be done before the 1.2 cutoff. Any disagreement? Labels changed: added priority-soon, go1.2, feature, removed priority-triage. Owner changed to @adg. Status changed to Accepted. |
https://golang.org/cl/13180043 Status changed to Started. |
This issue was closed by revision 466001d. Status changed to Fixed. |
This issue was closed by revision 27f4166. Status changed to Fixed. |
And that was the undo CL closing it again :/ New CL https://golang.org/cl/13324045/ Status changed to Started. |
Comment 17 by andrew@happyinspector.com: +1 I have something where I have a some common fields (id, path, revision, etc) and I use an anonymous struct that is embedded in other structs. However, I can't implement a custom json marshal on the common struct as then all the other structs will only return the output from the marshalled common fields. |
Comment 18 by andrew@happyinspector.com: +1 I have something where I have some common fields (id, path, revision, etc) and I use an anonymous struct that is embedded in other structs. However, I can't implement a custom json marshal on the common struct as then all the other structs will only return the output from the marshalled common fields. |
+1 |
This comment was marked as off-topic.
This comment was marked as off-topic.
Not for Go 1.9. I hope to take a look at all the open json proposals this summer and try to see if a coherent picture emerges. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Needed until the ancient Go issue is fixed: golang/go#6213
Just ran into this. The use of anonymous structs for inlining is excellent up until your anonymous struct has a |
Apparently there is no "inline" struct tag that encoding/json recognizes. kubernetes.git says `json:",inline"` all over the place, but that's not actually a thing, and doesn't do anything. What's actually making those fields be inline is that they're embedded fields (the field doesn't have a name; just a type). See also: golang/go#6213 I've never ever felt the Mandela effect strong like this before. I guess seeing it in kubernetes.git really messed with my head? I can't stop people from seeing `json",inline"` in kubernetes.git, but I can stop them from seeing it in our codebase. So save others (and myself?) from future confusion.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
In #42417 I proposed to have the following syntax:
So |
|
The |
@smoyer64, that's doesn't fix the issue I mentioned:
However, today:
|
by bjruth:
Edited by @dsnet on 2020-11-10 to fix formatting.
The text was updated successfully, but these errors were encountered: