You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was reported and fixed for an individual case in #66. #66 (comment) lists a few more fields with the same problem, but that list is also not complete. As one more example, I ran into this for ErrorResponseBody.Error:
The issue is that Go cannot set this fields to nil and will instead when parsing create an empty struct. Then when that message is serialized again, it will not be omitted as requested, but the empty values will be written to JSON, in my case leading to something like
I think the correct fix would be to go through and make all non-pointer struct fields that have omitempty on them, and turn them into pointers. Do you agree with this solution? Then I could look into preparing a PR for this.
The text was updated successfully, but these errors were encountered:
This is needed so that unset JSON values get initialized to `nil` in Go
instead of the zero struct. The zero struct is indistinguishable from an
explicitly set struct with zero values, and will get serialized despite
"omitempty". `nil` on the other hand will be dropped, as expected.
Fixesgoogle#72.
This was reported and fixed for an individual case in #66. #66 (comment) lists a few more fields with the same problem, but that list is also not complete. As one more example, I ran into this for
ErrorResponseBody.Error
:go-dap/schematypes.go
Line 104 in f58c894
The issue is that Go cannot set this fields to
nil
and will instead when parsing create an empty struct. Then when that message is serialized again, it will not be omitted as requested, but the empty values will be written to JSON, in my case leading to something likeinstead of
and that then confuses VS Code and others.
I think the correct fix would be to go through and make all non-pointer struct fields that have omitempty on them, and turn them into pointers. Do you agree with this solution? Then I could look into preparing a PR for this.
The text was updated successfully, but these errors were encountered: