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

disable anchors in stringify #211

Closed
dudif91 opened this issue Dec 3, 2020 · 3 comments
Closed

disable anchors in stringify #211

dudif91 opened this issue Dec 3, 2020 · 3 comments

Comments

@dudif91
Copy link

dudif91 commented Dec 3, 2020

hi, is there a way to disable anchors such as &a1 when using stringify.

I'm using YAML version 1.10.0

tnx

@eemeli
Copy link
Owner

eemeli commented Dec 3, 2020

I'm pretty sure that using just YAML.stringify() that isn't possible, but this will probably do what you want:

const doc = new YAML.Document()
doc.setSchema()
doc.contents = doc.schema.createNode(yourValueHere)
String(doc)

The reason why that works is that in v1 the automatic reference detection was a part of the stringify method in particular, while createNode didn't include it. This changes (along with some of the clumsiness of the above API) in v2, but that's an entirely different issue.

@dudif91
Copy link
Author

dudif91 commented Dec 6, 2020

tnx that was very helpful

@dudif91 dudif91 closed this as completed Dec 6, 2020
@ushuz
Copy link

ushuz commented Apr 3, 2021

I'm pretty sure that using just YAML.stringify() that isn't possible, but this will probably do what you want:

Can this be made into an option of stringify()?

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

No branches or pull requests

3 participants