SaveJson(filePath, data, ensurePath) Last updated: 23. Oct 2024
API only function
Saves data as a JSON file to Docly with specified content stringified to JSON format. This function is ideal for storing structured data in a standardized format. For more advanced document saving with custom schemas, consider using the "SaveFile" function.
Parameters
Name | Type | Description |
---|---|---|
filePath | string | The absolute path where the JSON file will be saved in Docly. Ensure the path is correct and includes the desired filename with a .json extension. |
data | object | The data to be stored, which will be automatically converted to JSON on the server side. If a string is provided instead of an object, it will be saved directly as text without JSON conversion. |
ensurePath | bool | If true the folder path will be created if it is missing. Default is false. |
Returns
Returns a reference to the saved file, including a timestamp and a unique GUID for the file, allowing for easy identification and retrieval.
Example
Code example (JS)
JS is normal JavaScript either running in the browser or on the Docly™ server.// This will save a file to Docly in JSON format and ensure the path exists (if not it will create the folder "Test Files")
let data = { "Property" : "Test value" };
docly.saveJson("Test files/Test.json", data, true);