Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!options) {
options = {};
}
JsonFile.validateNoUndefinedMembers(newJsonObject);
let stringified: string;
if (previousJson !== '') {
// NOTE: We don't use mode=json here because comments aren't allowed by strict JSON
stringified = jju.update(previousJson, newJsonObject, {
mode: 'cjson',
indent: 2
});
} else if (options.prettyFormatting) {
stringified = jju.stringify(newJsonObject, {
mode: 'json',
indent: 2
});
} else {
stringified = JSON.stringify(newJsonObject, undefined, 2);
}
// Add the trailing newline
stringified = Text.ensureTrailingNewline(stringified);
if (options && options.newlineConversion) {
switch (options.newlineConversion) {
case NewlineKind.CrLf:
return Text.convertToCrLf(stringified);
case NewlineKind.Lf:
return Text.convertToLf(stringified);
function json2json(data) {
var JSON5 = require("jju")
return JSON5.stringify(JSON.parse(data.toString("utf8")))
}
function toJSON5(src) {
var dest = path.join(path.dirname(src), path.basename(src, path.extname(src)) + '.json5');
var obj = JSON.parse(fs.readFileSync(src, 'utf8'));
fs.writeFileSync(dest, jju.stringify(obj, null, 4), 'utf8');
}
'jju': function jjuSerializer(obj, serializerOptions) {
return jju.stringify(obj, serializerOptions);
},
'json': function jsonSerializer(obj, serializerOptions) {