-
-
Notifications
You must be signed in to change notification settings - Fork 774
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_multi_constructor equivalent / unknown tag handler #385
Comments
This would be extremely useful to me. I'm processing AWS CloudFormation templates with js-yaml. CloudFormation uses a number of tags as macros, e.g. Currently, in order to do that, I have to hard-code a list of tags used by AWS and define a type for each tag, for each kind of node (because some AWS tags are used for more than one kind of node). This is a pain, it will break if AWS starts supporting additional tags, and it makes otherwise-simple processing code harder to understand. This feature request would drastically simplify this task. |
I'm interested in this feature as well. Currently working on deserializing various yaml scripts we get from customers. They're predictable but we could encounter an unknown tag |
Added in 73ef02c (currently in See an example how to do it here: |
In PyYAML, I can use the
add_multi_constructor
feature to allow me to define a constructor for multiple tags. I am using it to handle any unknown tags. For example, I could use this to deserialize the documentinto the JS structure
and be able to re-serialize that structure back into equivalent yaml.
My use case is to read and modify a tiny part of a big yaml file that has a bunch of domain-specific tags in it. I don't care how the tags are resolved as I'm not reading that part of the file, but currently with js-yaml I can't read it at all because to parse the file in the first place results in an unknown tag error. Even if I set it to skip unknown tags, I can't re-serialize the modified docjument.
This is fine with PyYAML as I can use
add_multi_constructor
as defined above to handle any unknown tags, but as far as I can tell this behvaiour is impossible to achieve with js-yaml.The text was updated successfully, but these errors were encountered: