Another way to load the JSON data into a global object is to listen for the app start event and reference the JSON data with a global variable:
(function () {
var app = pc.Application.getApplication();
app.on('start', function() {
var jsonAssets = app.assets.findByTag('json-data');
// Assuming the json asset is preloaded and it's the only one
if (jsonAssets.length > 0 && jsonAssets[0].loaded) {
window.someJsonData = jsonAssets[0].resource;
}
});
})();
Example project here: https://playcanvas.com/editor/scene/929169
In regards to access other script instances and components, I cover some of it here: How to refer to different parts of the API while scripting
TLDR, you need to have a reference to the entity that has the script instance or component you want to access. To get that entity reference in the first place, you can either search for it with the various ‘findBy’ functions or have a script attribute that allows you make the reference in the Editor (example on line 3 on this script: https://playcanvas.com/editor/code/405842?tabs=4468263).