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

Exclamation mark or Node Tags are breaking the serialization #289

Closed
oscarsan opened this issue May 26, 2016 · 2 comments
Closed

Exclamation mark or Node Tags are breaking the serialization #289

oscarsan opened this issue May 26, 2016 · 2 comments

Comments

@oscarsan
Copy link

When using Node Tags as defined in the YAML specs here the serialization is throwing an exception

In the sample

%YAML 1.2

---
!XL.Handler
Configuration: 
  Beacon: 
    UseBuzzer: True
  WidthAdjustment: 
    EnableWidthAdjustment: False
    ConveyorWidth: 1150
    ConveyorWidthOffset: 2000

Im getting a

unknown tag !<!XL.Handler> at line 11, column 1:

@dervus
Copy link
Collaborator

dervus commented May 26, 2016

You must define a type for that tag as shown in custom_types example: https://github.com/nodeca/js-yaml/tree/master/examples

@oscarsan
Copy link
Author

Thanks, need much less than in the example, but it works

    var ConfigYamlType = new jsyaml.Type('!XL.Handler', {
      kind: 'mapping',
      construct: function (data) {
            return data;
      }
    });
    var CONFIG_SCHEMA = jsyaml.Schema.create([ ConfigYamlType ]);
    var loaded = jsyaml.load(response, { schema: CONFIG_SCHEMA });

It is just enough in this case to return the data.

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

No branches or pull requests

2 participants