Skip to content

Defold NE for cjson encode and decode JSON

Notifications You must be signed in to change notification settings

Melsoft-Games/defold-cjson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Defold-CJSON

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

Platforms

  • iOS
  • Android
  • MacOS
  • Windows

Setup

You can use the Defold-CJSON extension in your own project by adding this project as a Defold library dependency. Open your game.project file and in the dependencies field under project add:

https://github.com/Melsoft-Games/defold-cjson/archive/master.zip

Or point to the ZIP file of a specific release.

API

cjson.encode(lua_table)

return encoded lua table to json string

cjson.decode(valid_json)

return parsed lua_table

Note: json must be valid, or cjson will throw error. You can wrap it with pcall, or change extension and call cjson safe_decode from lua-cjson lib

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

License, Authors

MIT license This NE wrapped by Denis Smirnov

Original module: lua-cjson License

Issues and suggestions

If you have any issues, questions or suggestions please create an issue or contact me: [email protected]

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages