using and storing json text in JavaScript -


i'm making 2d, top-down zelda-style web single player rpg...

i'd store dialog in json format...

currently i'm getting json external javascript file. json stored such in js/json.js:

function getjson() {  var json = {     "people" :      [         {//npc 1 - rescue dog  etc... 

then use in main game javascript file such <script src="js/json.js"></script>..`

var json = getjson(); 

then use such:

labels[index].text = json.people[index].dialogs.start.texts[0]; 

does matter if keep json js file in javascript function? or should stored .txt file parsed?

thanks!

it not matter json data javascript store .js , later on can add more data related functions if needed, btw data file has getjson function doesn't make sense store .txt

on other hand if api serving data need not have extension @ all.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -