We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MarshalJSON()
omitempty
I have a schema with a UUID property. It has a regexp to validate its contents, but isn't marked as required:
"uuid": { "type": "string", "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" }
Non-required fields get an omitempty added to their json struct tag:
json
Uud string `json:"uuid,omitempty"`
However, MarshalJSON doesn't understand omitempty, so it always emits the field:
MarshalJSON
{"uuid": ""}
This causes schema validation to fail, since the empty string doesn't match the declared pattern.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have a schema with a UUID property. It has a regexp to validate its contents, but isn't marked as required:
Non-required fields get an
omitempty
added to theirjson
struct tag:However,
MarshalJSON
doesn't understandomitempty
, so it always emits the field:This causes schema validation to fail, since the empty string doesn't match the declared pattern.
The text was updated successfully, but these errors were encountered: