Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Tatskaari
Copy link
Member

Converts a asp object to a yaml string.

@Tatskaari Tatskaari changed the title Add a yaml() builtin like the python one Add a yaml() builtin like the json one Nov 29, 2024
Copy link

@zgeor zgeor left a 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
Copy link
Collaborator

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) {
Copy link
Collaborator

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

Copy link
Collaborator

@peterebden peterebden left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants