Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Hi, I want to use some information within the home.json file which is in the same directory of home.js.
How to load this JSON?
I read this article, https://community.ptc.com/t5/Vuforia-Studio/How-to-include-a-json-file-from-Vuforia-Studio-resources/m-p/729025#M9801
but it uses the /resources/uploaded folder.
Many thanks
Solved! Go to Solution.
Hi @GianVal ,
you can use the mentioned technique also to load the Home.json. It is only a different path what could you check in the project folder - e.g.:
let my_file='Home.json'
$http.get('app/components/' + my_file).
success(function(data, status, headers, config) { console.log("-->calling succeeded");
let myJsonData=data;// in this case is $scope.modelData['model-1']='Info.json';
console.warn(myJsonData);
})
.error(function(data, status, headers, config) {console.log("-->calling failed");
});
This will print the Home.json to the console in preview mode. e.g.:
Hi @GianVal ,
you can use the mentioned technique also to load the Home.json. It is only a different path what could you check in the project folder - e.g.:
let my_file='Home.json'
$http.get('app/components/' + my_file).
success(function(data, status, headers, config) { console.log("-->calling succeeded");
let myJsonData=data;// in this case is $scope.modelData['model-1']='Info.json';
console.warn(myJsonData);
})
.error(function(data, status, headers, config) {console.log("-->calling failed");
});
This will print the Home.json to the console in preview mode. e.g.:
Hi, I'm using this method to read an external JSON file. How can I use the retrieved file in the whole code as a "global variable"?
e.g. read a json-> get a JSON element to use in another function
Many thanks
without the check more detailed I think the following options could be used