Defold-CJSON

logo

Defold CJSON

Defold NE for cjson encode and decode JSON

Defold-CJSON Native Extension for the Defold Game Engine

This extension allow you encode lua table to JSON and decode JSON to lua table in native part.

Github Link
Asset Link

Short API:

cjson.encode(lua_table)

  • return encoded lua table to json string

cjson.decode(valid_json)

  • return parsed lua_table

Examples you can find in GitHub repository

Benchmark

rxlua - pure lua JSON encode/decode implementation

time in ms

Json: 4KB 971KB 1.8MB
defold decode 0 0.032 0.075
– – – –
rxlua encode 0 0.0734 0.148
rxlua decode 0.0003 0.0308 0.051
– – – –
cjson encode 0 0.0057 0.0122
cjson decode 0 0.0066 0.0117

Notes

This is extension, what we use in Family Age
If you will use our extension and find some bugs or have some suggestions, you are welcome, tell about it!
NE wrapped by @denis.smirnov.by

26 Likes

Thank you for sharing this and the other extensions you released today! Much appreciated!

5 Likes

Amazing! Thank you!

Lua lib faster than Defold decode? O_o
which platform is it?

5 Likes

I am tested before publishing

This times i got from my MacBook Air’2017. This 3 JSONs in repository examples, so you can test by youself and write your time to compare it with my tests

3 Likes

I added support for hashed strings and vector3 - https://github.com/DreamRealityInteractive/defold-cjson/tree/serialize_hash_vector3
I can open a pull request if it’s useful? But you may prefer not to handle those types.

4 Likes