Skip to main content

@webda/coreReadme | API


Variable: JSONUtils

const JSONUtils: Object

Simple JSON utils

Type declaration

duplicate

duplicate: (value) => any

Duplicate an object using serializer

Parameters

value: any

Returns

any

loadFile

loadFile: (filename) => any

Helper to FileUtils.save

Parameters

filename: string

Returns

any

parse

parse: (value) => any

Parse a JSON data

Parameters

value: any

to parse

Returns

any

object parsed

safeStringify

safeStringify: (value, replacer, space, publicAudience) => string

Safe Stringify stringify a object included circular object and also remove any attributes starting with a __

Parameters

value: any

replacer: (key, value) => any= undefined

space: string | number= 2

publicAudience: boolean= false

Returns

string

saveFile

saveFile: (object, filename, publicAudience?) => void

Helper to FileUtils.save

Parameters

object: any

filename: string

publicAudience?: boolean

Returns

void

sortObject

sortObject: (unordered, transformer) => any

Sort object keys

Parameters

unordered: any

transformer: (obj) => any= undefined

Returns

any

stringify

stringify: (value, replacer, space, publicAudience) => string

See JSON.stringify

Parameters

value: any

replacer: (key, value) => any= undefined

space: string | number= 2

publicAudience: boolean= false

Returns

string

updateFile

updateFile: (filename, replacer) => Promise<void>

Visit a json/jsonc file for update

Parameters

filename: string

replacer: (value) => any

Returns

Promise<void>

Source

packages/core/src/utils/serializers.ts:311