Home > @rushstack/node-core-library > JsonFile

JsonFile class

Utilities for reading/writing JSON files.

Signature:

export declare class JsonFile 

Methods

Method Modifiers Description
load(jsonFilename) static Loads a JSON file.
loadAndValidate(jsonFilename, jsonSchema, options) static Loads a JSON file and validate its schema.
loadAndValidateAsync(jsonFilename, jsonSchema, options) static An async version of JsonFile.loadAndValidate().
loadAndValidateWithCallback(jsonFilename, jsonSchema, errorCallback) static Loads a JSON file and validate its schema, reporting errors using a callback
loadAndValidateWithCallbackAsync(jsonFilename, jsonSchema, errorCallback) static An async version of JsonFile.loadAndValidateWithCallback().
loadAsync(jsonFilename) static An async version of JsonFile.load().
parseString(jsonContents) static Parses a JSON file’s contents.
save(jsonObject, jsonFilename, options) static Saves the file to disk. Returns false if nothing was written due to options.onlyIfChanged.
saveAsync(jsonObject, jsonFilename, options) static An async version of JsonFile.loadAndValidateWithCallback().
stringify(jsonObject, options) static Serializes the specified JSON object to a string buffer.
updateString(previousJson, newJsonObject, options) static Serializes the specified JSON object to a string buffer.
validateNoUndefinedMembers(jsonObject) static Used to validate a data structure before writing. Reports an error if there are any undefined members.