In an effort to improve on our internal apis, and the current functionality, I’d like to know if you are currently using our dmJson api?
The engine itself doesn’t need that api, and frankly, the implementation (jsmn.c) leaves a lot to desire in terms of performance. Also, the api itself isn’t great.
Our wish is to remove that api entirely, which would be a breaking change.
If our users are actually using the dmJson api, I’ll create a separate extension with that functionality.
(Personally, I’d use another C library entirely due to it’s poor performance)
We’ll use another json parser that does the conversion lua<->string.
As such, we will still support json.encode()/json.decode()
We don’t need a DOM api to do that. In fact, a “sax” style parser uses less memory and is generally faster. We’ll likely use the lua-cjson library (which the defold-cjson is based on)
It would be a breaking change! YaGames, JsToDef plus a bunch of official extensions (Facebook, Push, IAP etc) use dmJson.
I see that all those extensions share almost the same piece of code (JsToDef vs IAP). So, if you write a short guide on how to migrate from dmJson to another lib, it will help a lot.
This is why I wanted to know the scope of things.
Although we try to avoid doing breaking changes, it doesn’t mean we won’t do them when we feel we need to.
In the case of the dmJson API, it wasn’t really an api, and as such, we couldn’t really swap out the backend. Also, while doing this, I realized that the engine itself doesn’t actually need the api.
And, if we’re doing a breaking change, why not try to make the best out of it.
So, we’ll remove the C++ api (and we may implement a C++ api as an extension, but only if necessary, hence this post)
As for the cases you pointed out (there are several), we have changed the API somewhat for dmScript::JsonToLua() so that it doesn’t take the old dmJson::Document* pointer. As such, it will be a lot simpler (and faster!) to convert to and from Lua and the string:
int dmScript::JsonToLua(lua_State* L, const char* json, size_t json_len);
int dmScript::LuaToJson(lua_State* L, char** json, size_t* json_len);
Imho, it will make the code easier to read and maintain, and the main hassle of upgrading the extensions, will be the version numbers/releases (it’s easy to miss an extension that uses this api)