Loading a JS file to a string

Loading a JS file to a string
0.0 0



Is it possible to load the contents of a JS file to a string? For example, if I wanted to include some static JSON content with my game and load it in to a string/object and work with it, is that possible?


— Joel

Parsing flat text file and store the data in data structures?

Sure, if you are using the latest version, 2.1.2-hotfix, you could simply achieve that by *cc.FileUtils.getInstance().getStringFromFile(filename)*.


don’t know if this help.

i am currently in HTML5 and not yet implement the game to JS Binding.
i use JQuery

$.get(‘res/stg001’, function(result) {

to get my local file stg001 (which is simply a JSON string)