78 lines
3.1 KiB
TypeScript
Raw Normal View History

2023-10-09 20:21:00 +11:00
import { IParseOptions, IStringifyOptions, Reviver } from "jsonc/lib/interfaces";
2023-06-11 15:10:34 +10:00
import { ILogger } from "../models/spt/utils/ILogger";
import { HashUtil } from "./HashUtil";
import { VFS } from "./VFS";
export declare class JsonUtil {
protected vfs: VFS;
protected hashUtil: HashUtil;
protected logger: ILogger;
protected fileHashes: any;
protected jsonCacheExists: boolean;
2023-10-09 20:21:00 +11:00
protected jsonCachePath: string;
2023-06-11 15:10:34 +10:00
constructor(vfs: VFS, hashUtil: HashUtil, logger: ILogger);
/**
* From object to string
* @param data object to turn into JSON
2023-10-09 20:21:00 +11:00
* @param prettify Should output be prettified
2023-06-11 15:10:34 +10:00
* @returns string
*/
2023-10-09 20:21:00 +11:00
serialize(data: any, prettify?: boolean): string;
/**
* From object to string
* @param data object to turn into JSON
* @param replacer An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified.
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
* @returns string
*/
serializeAdvanced(data: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
/**
* From object to string
* @param data object to turn into JSON
* @param filename Name of file being serialized
* @param options Stringify options or a replacer.
* @returns The string converted from the JavaScript value
*/
serializeJsonC(data: any, filename?: string | null, options?: IStringifyOptions | Reviver): string;
serializeJson5(data: any, filename?: string | null, prettify?: boolean): string;
2023-06-11 15:10:34 +10:00
/**
* From string to object
* @param jsonString json string to turn into object
2023-10-09 20:21:00 +11:00
* @param filename Name of file being deserialized
2023-06-11 15:10:34 +10:00
* @returns object
*/
deserialize<T>(jsonString: string, filename?: string): T;
2023-10-09 20:21:00 +11:00
/**
* From string to object
* @param jsonString json string to turn into object
* @param filename Name of file being deserialized
* @param options Parsing options
* @returns object
*/
deserializeJsonC<T>(jsonString: string, filename?: string, options?: IParseOptions): T;
deserializeJson5<T>(jsonString: string, filename?: string): T;
2023-06-11 15:10:34 +10:00
deserializeWithCacheCheckAsync<T>(jsonString: string, filePath: string): Promise<T>;
2023-10-09 20:21:00 +11:00
/**
* From json string to object
* @param jsonString String to turn into object
* @param filePath Path to json file being processed
* @returns Object
*/
2023-06-11 15:10:34 +10:00
deserializeWithCacheCheck<T>(jsonString: string, filePath: string): T;
2023-10-09 20:21:00 +11:00
/**
* Create file if nothing found
* @param jsonCachePath path to cache
*/
protected ensureJsonCacheExists(jsonCachePath: string): void;
/**
* Read contents of json cache and add to class field
* @param jsonCachePath Path to cache
*/
protected hydrateJsonCache(jsonCachePath: string): void;
/**
* Convert into string and back into object to clone object
* @param objectToClone Item to clone
* @returns Cloned parameter
*/
clone<T>(objectToClone: T): T;
2023-06-11 15:10:34 +10:00
}