-
Notifications
You must be signed in to change notification settings - Fork 207
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
Add a yaml() builtin like the json one #3308
base: master
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.
Thanks! Exactly what I needed
def yaml(value) -> str: | ||
"""Returns a YAML-formatted representation of a plz value. | ||
""" | ||
pass |
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.
nit: pass
is unnecessary
@@ -107,6 +107,13 @@ func (b pyBool) MarshalJSON() ([]byte, error) { | |||
return []byte("false"), nil | |||
} | |||
|
|||
func (b pyBool) MarshalYAML() (interface{}, error) { |
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.
should this be part of the pyObject interface? I think MarshalJSON is
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.
Thinking further about this, I'm not sure this is really necessary. As someone pointed out internally, JSON is a subset of YAML, so emitting it via the json()
builtin would also be valid YAML for anything that wanted to consume that.
Converts a asp object to a yaml string.