hello I am trying to access a JSON file to my nativescrpt project. i tried this
let fs = require("tns-core-modules/file-system");
let documents = fs.knownFolders.currentApp();
function GetJsonData(callback) {
let filePath = documents.getFile("./shared/message.json");
let array;
let jsonData;
jsonFile.readText().then(function (content) {
try {
jsonData = JSON.parse(content);
array = new observableArrayModule.ObservableArray(jsonData);
} catch (err) {
throw new Error('Could not parse JSON file');
}
}, function (error) {
throw new Error('Could not read JSON file');
});
function showJsonData() {
GetJsonData((array) => {
console.log(array);
});
}
but it is failed to get data from JSON file