optjson.go better handling of zero value #24695
Labels
~backend
Backend-related issue.
bug
Something isn't working as documented
~engineering-initiated
Engineering-initiated story, such as a bug, refactor, or contributor experience improvement.
#g-mdm
MDM product group
:incoming
New issue in triage process.
:release
Ready to write code. Scheduled in a release. See "Making changes" in handbook.
~released bug
This bug was found in a stable release.
💥 Actual behavior
Given a struct such as
If you were to initialize this struct without specifying
SomeID
Marshaling this object will product
🧑💻 Steps to reproduce
Discovered during #24658
You can reproduce by creating a patch request to the policies endpoint with a struct that does not define
ScriptID
orSoftwareTitleID
Notice how the json that is generated for this struct looks like:
🕯️ More info (optional)
https://victoronsoftware.com/posts/go-json-unmarshal/
🛠️ To fix
Is there a way to change
optjson.go
to not output the key if theSet
is equal tofalse
. Can we use theomitempty
tag to get the intended behavior.The text was updated successfully, but these errors were encountered: