Cocos Creator js Read, Write File like (plist or xml, json)?

Cocos Creator js Read, Write File like (plist or xml, json)?
0.0 0


I looked in cocos creator document and I don’t find any clue about CRUD file.
The reason i asking this, because i have define my game data structure in plist file, it such a big data structure and complicated, So do anybody have ideas about that stuff?
please kindly response I really need help for this.


The most pragmatic thing to do would be to define how you want your objects to look as you use them. Then define a javascript object to hold data in that structure, place it in a standalone .js file - which you access by going

var myData = require('mydata');


thank for reply.
You mean I need to implement standalone js code to work with that data file. if so, do they work on native build. I still worried about it.


You can read a json file like so
cc.loader.loadRes('SomeDirInResources/SomeJsonFile', (err, res) => this.parseData(err, res));
The file loaded needs to be referenced without extension.
For JSON files it just works but I don’t know what happens if you load a plist.


I use JSON files ro define everything in my game. Works great.
It would awesome if we also had a way to write JSON files (dont like to deal with localstorage…)