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

Changing a null value to a mapping results in [object Object] string value. #10

Open
kevinswiber opened this issue Sep 7, 2017 · 1 comment
Labels

Comments

@kevinswiber
Copy link
Contributor

When changing a null value to an object, it gets sent to replacePrimitive, which turns it into the string [object Object].

yawn-yaml/src/index.js

Lines 224 to 232 in d870fbe

if (newValue !== value && !isArray(valNode.value)) {
// replace the value node
yaml = replacePrimitive(valNode, newValue, yaml);
// remove the key/value from newJson so it's not detected as new pair in
// later code
delete newJson[keyNode.value];
}

@mohsen1 mohsen1 added the bug label Sep 7, 2017
@bubeck
Copy link

bubeck commented Nov 7, 2022

This is a test case showing the problem:

'use strict';

const YAWN      = require('yawn-yaml/cjs');

let str = `
  en-GB: ~
`;
let yawn = new YAWN(str);

let json = yawn.json;
json["en-GB"] = { key1: "test" };
yawn.json = json;

let str2 = yawn.yaml
console.log(str2);

// The output is
//  en-GB: [object Object]

// But I expect it to be
// en-GB:
//   key1: "test"

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

No branches or pull requests

3 participants