hjson-js icon indicating copy to clipboard operation
hjson-js copied to clipboard

When written with `keepWsc: true,` carries comments

Open lastuniverse opened this issue 3 years ago • 0 comments

raw hjson string

var text = '{\
    "last.access": true,\
    // "last.set": true,\
    // "skills.use": true,\
    // "last.wrap.*": true,\
}';

parse it and then base it back into text

var data = HJSON.parse(text, {keepWsc: true});
text = HJSON.stringify(data, {
    keepWsc: true,
    bracesSameLine: true,
    quotes: 'all',
    separator: true,
    space: '\t',
});

as a result, we get the following string

'{\
    "last.access": true    // "last.set": true,\
    // "skills.use": true,\
    // "last.wrap.*": true,\
}';

repeating these steps several times teaching such a line

'{\
    "last.access": true    // "last.set": true,    // "skills.use": true,    // "last.wrap.*": true,\
}';

lastuniverse avatar Jun 29 '21 22:06 lastuniverse