-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
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
Support marshal with linebreak and indent and support ignore specific struct field #150
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are essential here to understand what you're trying to achieve. Also, I'm not sure indentation should be handled in the MarshalJSON method.
var MarshalWithIndent = false | ||
var MarshalPrefix = "" | ||
var MarshalIndent = "\t" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Global variables should be avoided. Wouldn't you want to do this with the regular json.MarshalIndent
method directly?
@@ -122,6 +122,9 @@ type Reflector struct { | |||
// switching to just allowing additional properties instead. | |||
IgnoredTypes []any | |||
|
|||
// Ignore specific struct field, enable dynamic generate different schemas from on struct. | |||
Ignore func(reflect.StructField) bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its not clear how this should be used... as a rule, I'd try to avoid using reflect types directly.
Codecov. Minor renaming of comments handler
Add a custom mechanism for looking up comments.
Schema.MarshalJSON
marshal json with linebreak and indent, the default json output is still compact;Reflector.Ignore
method to ignore specific struct field, enable dynamic generate different schemas from one struct.