We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
As written in the title, yaml.dump adds quotes to some keys when using custom tags.
yaml.dump
I've made a code sandbox (you can find here) and below a code sample where the issue is visible:
// sample.ts import yaml from "js-yaml"; interface PoseType { x: number; y: number; z: number; rx: number; ry: number; rz: number; rw?: number; } class PoseTag { public pose: PoseType; constructor(props: PoseType) { this.pose = props; } } const PoseYamlType = new yaml.Type("!Pose", { kind: "mapping", resolve: (data) => { const val = typeof data.x === "number" && typeof data.y === "number" && typeof data.z === "number" && typeof data.rx === "number" && typeof data.ry === "number" && typeof data.rz === "number" && typeof data.rw === ("number" || "undefined"); return val; }, construct: (data: PoseType) => new PoseTag(data), instanceOf: PoseTag, represent: (obj: PoseTag) => obj.pose }); // create schema const schema = yaml.DEFAULT_SCHEMA.extend([PoseYamlType]); const testPose: PoseType = { x: 2.46, y: 26.853, z: -9.792, rx: -0.969, ry: -0.001, rz: -0.233, rw: 0.078 }; const obj = new PoseTag(testPose); const output = yaml.dump(obj, { schema: schema }); console.log(output);
expected output:
!Pose x: 2.46 y: 26.853 z: -9.792 rx: -0.969 ry: -0.001 rz: -0.233 rw: 0.078
received:
!Pose x: 2.46 'y': 26.853 # <--- z: -9.792 rx: -0.969 ry: -0.001 rz: -0.233 rw: 0.078
The text was updated successfully, but these errors were encountered:
y without quotes is a boolean true value in YAML 1.0, old version of the spec: https://yaml.org/type/bool.html
y
true
so it's intentional, but we probably should drop support for that at some point
Sorry, something went wrong.
gonna close this, duplicate of #645
you can use
yaml.dump(obj, { schema: schema, noCompatMode: true });
it may be subject to change (maybe true by default) in next major version
No branches or pull requests
As written in the title,
yaml.dump
adds quotes to some keys when using custom tags.I've made a code sandbox (you can find here) and below a code sample where the issue is visible:
expected output:
received:
The text was updated successfully, but these errors were encountered: