mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 06:10:44 -05:00
Replace json-fixer with jsonrepair (#1052)
The `fixJson` package is stale and `jsonrepair` is an active alternative. Seams to work well.
This commit is contained in:
commit
7c3b10d0de
@ -41,9 +41,9 @@
|
||||
"date-fns-tz": "~3.1",
|
||||
"fs-extra": "11.2.0",
|
||||
"i18n": "~0.15",
|
||||
"json-fixer": "~1.6",
|
||||
"json5": "~2.2",
|
||||
"jsonc": "~2.0",
|
||||
"jsonrepair": "3.11.2",
|
||||
"logform": "~2.6",
|
||||
"mongoid-js": "~1.3",
|
||||
"reflect-metadata": "~0.2",
|
||||
|
@ -1,10 +1,10 @@
|
||||
import type { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { FileSystemSync } from "@spt/utils/FileSystemSync";
|
||||
import { HashUtil } from "@spt/utils/HashUtil";
|
||||
import fixJson from "json-fixer";
|
||||
import { parse, stringify } from "json5";
|
||||
import { jsonc } from "jsonc";
|
||||
import { IParseOptions, IStringifyOptions, Reviver } from "jsonc/lib/interfaces";
|
||||
import { jsonrepair } from "jsonrepair";
|
||||
import { inject, injectable } from "tsyringe";
|
||||
|
||||
@injectable()
|
||||
@ -153,10 +153,13 @@ export class JsonUtil {
|
||||
let savedHash = this.fileHashes[filePath];
|
||||
if (!savedHash || savedHash !== generatedHash) {
|
||||
try {
|
||||
const { data, changed } = fixJson(jsonString);
|
||||
const fixedJsonString = jsonrepair(jsonString);
|
||||
const data = this.deserialize<T>(fixedJsonString);
|
||||
const changed = jsonString !== fixedJsonString;
|
||||
|
||||
if (changed) {
|
||||
// data invalid, return it
|
||||
this.logger.error(`${filePath} - Detected faulty json, please fix your json file using VSCodium`);
|
||||
this.logger.error(`${filePath} - Detected faulty JSON, please fix using a validator`);
|
||||
} else {
|
||||
// data valid, save hash and call function again
|
||||
this.fileHashes[filePath] = generatedHash;
|
||||
|
Loading…
x
Reference in New Issue
Block a user