Rush StackShopBlogEvents
Skip to main content

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

JsonFile class

Utilities for reading/writing JSON files.

Signature:

export declare class JsonFile 

Methods

MethodModifiersDescription
load(jsonFilename, options)staticLoads a JSON file.
loadAndValidate(jsonFilename, jsonSchema, options)staticLoads a JSON file and validate its schema.
loadAndValidateAsync(jsonFilename, jsonSchema, options)staticAn async version of JsonFile.loadAndValidate().
loadAndValidateWithCallback(jsonFilename, jsonSchema, errorCallback, options)staticLoads a JSON file and validate its schema, reporting errors using a callback
loadAndValidateWithCallbackAsync(jsonFilename, jsonSchema, errorCallback, options)staticAn async version of JsonFile.loadAndValidateWithCallback().
loadAsync(jsonFilename, options)staticAn async version of JsonFile.load().
parseString(jsonContents, options)staticParses a JSON file's contents.
save(jsonObject, jsonFilename, options)staticSaves the file to disk. Returns false if nothing was written due to options.onlyIfChanged.
saveAsync(jsonObject, jsonFilename, options)staticAn async version of JsonFile.save().
stringify(jsonObject, options)staticSerializes the specified JSON object to a string buffer.
updateString(previousJson, newJsonObject, options)staticSerializes the specified JSON object to a string buffer.
validateNoUndefinedMembers(jsonObject)staticUsed to validate a data structure before writing. Reports an error if there are any undefined members.