cocos3——6.js读取策划json配置表

1.excel转json

这个可以参见前辈python的方式:

https://github.com/gdgoldlion/ExcelAndJSON

不过这个需要装python和xlrd,装xlrd的时候需要用命令:

python setup.py install

在win32上用批处理这样转换excel到json:

python %~dp0../src/excel_and_json.py singlebook -o ./ -i test.xlsx


2.js里读取json

fs.readFile = function (file) {
    var path = this.fullPath(file);
    return jsb.fileUtils.getStringFromFile(path);
}

fs.readJson = function (file) {
    var data = this.readFile(file);
    var ret;
    try {
        ret = JSON.parse(data);
    } catch (e) {
        console.log('read json ',file,' error.');
    }

    return ret;
}

相关文章

    本文实践自 RayWenderlich、Ali Hafizji 的文章《...
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@1...
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从C...
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发...
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《...
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试...