Skip to content

Commit 9d5ce16

Browse files
committed
Fix a minor issue where JsonFile.updateString() didn't parse comments
1 parent ef5103e commit 9d5ce16

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎libraries/node-core-library/src/JsonFile.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ export class JsonFile {
127127
let stringified: string;
128128

129129
if (previousJson !== '') {
130+
// NOTE: We don't use mode=json here because comments aren't allowed by strict JSON
130131
stringified = jju.update(previousJson, newJsonObject, {
131-
mode: 'json',
132+
mode: 'cjson',
132133
indent: 2
133134
});
134135
} else if (options.prettyFormatting) {

‎libraries/node-core-library/typings/jju/jju.d.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface IJjuParseOptions {
66
reserved_keys? : 'ignore' | 'throw' | 'replace';
77
null_prototype?: boolean;
88
reviver?: (key: any, value: any) => any;
9-
mode?: 'json' | 'json5' | undefined;
9+
mode?: 'json' | 'cjson' | 'json5' | undefined;
1010
}
1111

1212
interface IJjuStringifyOptions {
@@ -16,7 +16,7 @@ interface IJjuStringifyOptions {
1616
sort_keys?: boolean;
1717
replacer?: (key: string, value: any) => any;
1818
no_trailing_comma?: boolean;
19-
mode?: 'json' | 'json5' | undefined;
19+
mode?: 'json' | 'cjson' | 'json5' | undefined;
2020
}
2121

2222
interface IJjuUpdateOptions extends IJjuParseOptions, IJjuStringifyOptions {

0 commit comments

Comments
 (0)