-2

I am referring code one of my colleague and he used Var in JSON file is there any specific reason behind it or he wants to use JS file.

He also mentioned <script type="text/javascript" src="player-settings.json"></script>

JSON:

var globalSettings ={  
         //data
};
var languageToSelect ={  
   "en":"English"
}; 
var menuSettings ={  
   "name":"Menu",
   "isStrictlyLinear":false,
   "pageCompleteOnView":true,
   "completeAllInteraction":false,
   "modules":{  
            //data
   },
   "lessons":{  
            //data
   },
   "topics":{  
            //data
   },
   "pageCompletion":{  
            //data
   },
   "bodySettings":{  
      //data
   }
};

I referred this link to know why we used a script tag to load JSON but in my case, he used type as "text/javascript" and in JSON var is used which leads me to confusion. Is there any specific reason to use Var in JSON file?

Swanand Taware
  • 723
  • 2
  • 7
  • 32

3 Answers3

2

The extension used is just wrong, its a javascript file not a json file

Jiby Jose
  • 3,745
  • 4
  • 24
  • 32
1

That isn't JSON. It's JavaScript code. Please check this URL : http://json.org/

1

data you shared doesn't look like a json.

AZ_
  • 3,094
  • 1
  • 9
  • 19