RoadmapShopEvents
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)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)staticLoads a JSON file and validate its schema, reporting errors using a callback
loadAndValidateWithCallbackAsync(jsonFilename, jsonSchema, errorCallback)staticAn async version of JsonFile.loadAndValidateWithCallback().
loadAsync(jsonFilename)staticAn async version of JsonFile.load().
parseString(jsonContents)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.