关于cocos 3.x lua 启用cjson

本人菜鸟一枚。
lua解析json太慢啦。看到frameworks\cocos2d-x\external\lua 里有个cjson的目录,上网查了下又说没有启用这个,按照说法修改了代码,我在lua 直接local cjson=require “cjson” 还是不能用。
有成功用cjson的大神指教一下吗?cocos2d 3.12 lua

3.12不是很清楚,我用的3.4,是另外下载个以前quick版本的,把里边的quick-src/lua_extensions/cjson源码添加进来,可以在android,ios下编译,VS上用不了,另外还要自己注册到lua

#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32)
		luaopen_lua_extensions_more(L);//CJSON
	#endif

lua_extensions_more.c的只留下CJSon功能代码如下:

#include "lua_extensions_more.h"

#if __cplusplus
extern "C" {
#endif

// cjson
#include "cjson/lua_cjson.h"

#ifndef WP8

// filesystem

#endif


static luaL_Reg luax_exts[] = {
    {"cjson", luaopen_cjson_safe},
    {NULL, NULL}
};

void luaopen_lua_extensions_more(lua_State *L)
{
    // load extensions
    luaL_Reg* lib = luax_exts;
    lua_getglobal(L, "package");
    lua_getfield(L, -1, "preload");
    for (; lib->func; lib++)
    {
        lua_pushcfunction(L, lib->func);
        lua_setfield(L, -2, lib->name);
    }
    lua_pop(L, 2);
}

#if __cplusplus
} // extern "C"
#endif

1赞

官方的json对unicode解析不支持,我也手动加入了cjson,有兴趣可以交流

请问你的怎么加入csjon的?