Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Problem with json file


Problem with json file

Hi everyone, 

I'm trying to load a json file that I upload into Vuforia Studio. The file contains a sequence of instruction that I have to print in a label. 


The json file is like:

"Scollegare i cavi di collegamento indicati in giallo",
"svitare le quattro viti del basamento" ,
"Togliere il motore",
"Sostituire motore",
"Riposizionare motore nel basamento",
"Avvitare le quattro viti di sostegno",
"Collegare i cavi di alimentazione"
and the content of home.js like this one:

var myObj;
$scope.testJSON = function() {
myObj = JSON.parse(myJSON);
function() { console.log("Oops, something went wrong"); });

$scope.updateLabel = function(){

$scope.setWidgetProp( "step-description", "text", "Description");

switch ($["robot-arm-model"].currentStep) {

case 1:
text = myObj.steps[0];
$scope.setWidgetProp( "step-description", "text", text)
case 2:
text = myObj.steps[1];
$scope.setWidgetProp( "step-description", "text", text)
case 3:
text = myObj.steps[2];
$scope.setWidgetProp( "step-description", "text", text)
case 4:
text = myObj.steps[3];
$scope.setWidgetProp( "step-description", "text", text)
case 5:
text = myObj.steps[4];
$scope.setWidgetProp( "step-description", "text", text)
case 6:
text = myObj.steps[5];
$scope.setWidgetProp( "step-description", "text", text)
case 7:
text = myObj.steps[6];
$scope.setWidgetProp( "step-description", "text", text)



Once launched the preview nothing happen. Any suggestions?


Thank you


Hello leonardosella,


You can try this function in order to read and load your JSON file:


// where jsonFile is './app/resources/Uploaded/repair_sequence.json'
readJson = function(jsonFile) {
  fetch(jsonFile).then(response => {
    return response.text();
  }).then(data => {
    myObj= JSON.parse(data);
  }).catch(err => {
    console.log ("Oops, something went wrong");


  I hope this was helpful.


Kind regards,


Hello @lgherman , thank you for your reply.

I tried the piece of code: when load the experience into console appear "Failed to load resource: the server responded with a status of 500 (Internal Server Error)". This kind of error exit every time i try to load the .json script. 


Any suggestions? Thank you 

// $scope, $element, $attrs, $injector, $sce, $timeout, $http, $ionicPopup, and $ionicPopover services are available

filePath = 'app/resources/Uploaded/repair_sequence.json';
finishedLoading = false;

angular.element(document).ready(function () {

$scope.Init = function() { 
    // Reading the file asynchronously
      .success(function (data) {  
        finishedLoading = true;
    }).error(function (data, status, headers, config) {}) 	

$scope.updateLabel = function() {
  if(finishedLoading == true)  {
   		// do your logic 



Try the approach above. Also keep in mind that you must wait for the json to finish loading before reading from it. You can use a flag as I did in the example ( called finishedLoading )

Hi, the solution posted didn't work for my case. So, I choose to load a .txt file formatted with json-notation. Loading of the file takes place via xmlhttp as shown below. 


  • var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
    myObj = JSON.parse(this.responseText)

    // logic 

    };"GET", "app/resources/Uploaded/istruzioni_montaggio_lingue.txt", true);

Thanks for the help. 

5-Regular Member

Hello @leonardosella, the solution proposed by @lgherman works correctly.


It may be that your .json file is badly formatted.


I share an example:




Kind regard.



Hello Community.


It might be very helpful if someone can post a sample experience that contains a few steps and step description bind to a label. (especially for the non-coders)


Thanks in advance !




(Presales) Senior Technical Consultant @ INNEO Solutions GmbH (Germany)

Hello everyone,


Here is a an example of how to read a JSON file and use the data to set the text of a label.

I hope this is useful.


Kind regards,


5-Regular Member

Hi @lgherman 


Thanks for sharing an example.




Thank you Lorena for this example!

(Presales) Senior Technical Consultant @ INNEO Solutions GmbH (Germany)

I wanted to store players stats on a .JSON file. The problem is the file I made isn't appearing as an available resource in my file viewer in the editor. How do I get it to appear in my editor? can I use it even if it isn't shown as available?

edit: i've tried

Top Tags