Skip to main content
The Deno 2 Release Candidate is here
Learn more
Latest
class JsonUtil
Re-export
import { JsonUtil } from "https://deno.land/x/sptaki@1.2.0/utils/mod.ts";

Constructors

new
JsonUtil(
vfs: VFS,
hashUtil: HashUtil,
logger: ILogger,
)

Properties

protected
fileHashes: any
protected
hashUtil: HashUtil
protected
jsonCacheExists: boolean
protected
jsonCachePath: string
protected
logger: ILogger
protected
vfs: VFS

Methods

protected
ensureJsonCacheExists(jsonCachePath: string): void

Create file if nothing found

protected
hydrateJsonCache(jsonCachePath: string): void

Read contents of json cache and add to class field

clone<T>(objectToClone: T): T

Convert into string and back into object to clone object

deserialize<T>(jsonString: string, filename?: string): T

From string to object

deserializeJson5<T>(jsonString: string, filename?: string): T
deserializeJsonC<T>(
jsonString: string,
filename?: string,
options?: IParseOptions,
): T

From string to object

deserializeWithCacheCheck<T>(jsonString: string, filePath: string): T

From json string to object

deserializeWithCacheCheckAsync<T>(jsonString: string, filePath: string): Promise<T>
serialize(data: any, prettify?: boolean): string

From object to string

serializeAdvanced(
data: any,
replacer?: (
this: any,
key: string,
value: any,
) => any
,
space?: string | number,
): string

From object to string

serializeJson5(
data: any,
filename?: string | null,
prettify?: boolean,
): string
serializeJsonC(
data: any,
filename?: string | null,
): string

From object to string