Home > @microsoft/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.
loadAndValidateWithCallback(jsonFilename, jsonSchema, errorCallback) static Loads a JSON file and validate its schema, reporting errors using a callback
save(jsonObject, jsonFilename, options) static Saves the file to disk. Returns false if nothing was written due to options.onlyIfChanged.
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.