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

when converting objects (stringify, parse) incorrectly handles fields with undefined #58

Open
lastuniverse opened this issue Jul 28, 2023 · 0 comments

Comments

@lastuniverse
Copy link

lastuniverse commented Jul 28, 2023

import * as HJSON from 'hjson';

const text1 = "{test: 123}" // type taken from the config file
console.log(text1);  // "{test: 123}"

// then sequential reading, modification and writing of the config is simulated


const data1 = HJSON.parse(text1, {keepWsc:true});
console.log(data1); // {test: 123}

delete data1.test;
const text2 = HJSON.stringify(data1, {keepWsc:true});
console.log(text2); // "{test: undefined}"

const data2 = HJSON.parse(text2, {keepWsc:true});    
console.log(data2); //  {test: 'undefined'}   // unexpectedly undefined becomes a string
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

1 participant