Methods
# loadJSON(path, successCallback, failureCallback)
Loads the requested JSON file data from the requested path and returns the
JSON text as it appears in the file.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | File path to read from. |
successCallback |
Callback | Invoked if the load succeeded. |
failureCallback |
Callback | Invoked if the load failed. |
Example
rpgcode.loadJSON(
"Boards/start.board",
function(response) {
// Success callback.
console.log(response);
},
function(response) {
// Failure callback.
console.log(response);
}
);
# saveJSON(data, successCallback, failureCallback)
Saves the requested JSON data to the file specified, if the file does not
exist it is created. If the file does exist it is overwritten.
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | JSON object containing path and data properties. |
successCallback |
Callback | Invoked if the file save succeeded. |
failureCallback |
Callback | Invoked if the file save failed. |
Example
rpgcode.saveJSON(
{
path: "Boards/start2.board", // Subdirectory and file to save.
data: {"Test": "Hello world!"} // JSON data to store.
},
function(response) {
// Success callback.
console.log(response);
rpgcode.endProgram();
},
function(response) {
// Failure callback.
console.log(response);
rpgcode.endProgram();
}
);