Skip to content

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

Description

@lastuniverse
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions