-
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
acegoal07 edited this page Aug 29, 2022
·
10 revisions
This is wiki contains a breakdown of the package and how to use each function
npm i @acegoal07@json-editor
-
editFile
- Creates an editor instance for the specified file -
createFile
- Creates a json file -
createFileEditor
- Creates a new file and passes it with the editor attached already -
deleteFile
- Deletes the specified json file -
copyFile
- Duplicates the file you specify -
moveFile
- Moves the file from the old location to the new location -
renameFile
- Renames the specified file to the new provided name -
readFile
- Returns the data from the specified file -
readAllFiles
- Retunes a map filed with all the data from the files
const json = require("@acegoal07/json-editor");
json.createFile("display.json");
// Create a new json file
let file = json.editFile("display.json", {autosave: true});
// file content = {}
file.set("Hello", "world!");
file.set("toggle", true);
file.set("data", []);
// {
// "Hello": "world!",
// "toggle": true,
// "data": []
// }
console.log(file.get("Hello"))
// log => world!
file.push("data", "test");
file.push("data", "test2")
file.unshift("data", "test3");
file.set("items", {"world": "world!"});
file.unset("Hello");
// {
// "data": [
// "test3",
// "test",
// "test2"
// ],
// "items": {
// "world": "world!"
// }
// }
file.emptyArray("data");
file.emptyObject("items");
// {"data": [], "items": {}}
file.empty()
// {}
json.copyFile("display.json", "json/display.json");
json.deleteFile("display.json");
// Deletes the specified json file
json.renameFile("json/display.json", "show.json");
// Changes the name of the specified file