extension-fbinstant icon indicating copy to clipboard operation
extension-fbinstant copied to clipboard

Accept Lua tables as arguments and serialize to json in c land

Open britzl opened this issue 7 years ago • 1 comments
trafficstars

Currently the communication from Lua to JS via C requires complex data structures (Lua tables) to be serialized to JSON in Lua before passed on as a string to the extension and deserialized again in Javascript. The same process but in reverse goes for complex responses from Javascript back to Lua.

The preferred solution is to pass Lua tables to C and let the C code serialize to JSON. Currently there's no support for serializing a Lua table to JSON from C.

Task: Evaluation of JSON parsers in C. Integrate with extension.

  • https://github.com/zserge/jsmn
  • https://github.com/nlohmann/json
  • https://github.com/kazuho/picojson
  • And possibly others

Perhaps Lua table to JSON and back again should be part of the DMSDK?

britzl avatar Mar 16 '18 07:03 britzl

We use jsmn internally for json.encode(). This, together with a json.decode() from a yet to be decided lib, should be externalised and made available as part of DMSDK.

britzl avatar Mar 17 '18 13:03 britzl