HolyLib Wiki

AsyncTableToJSON

  util.AsyncTableToJSON( table tbl, function callback, boolean pretty )

Description

Turns the given table into a json string just like util.FancyTableToJSON but it will do this on a different thread.

Recently Added

This was recently added in version (0.73).

By giving the table to this function you make a promise to not modify the table while the json string is being created!
This is because we don't copy the table, we instead copy the pointer into a new Lua state where we then iterate/access it from another state/thread and if you modify it in any way you will experience a crash.
You still can access the table in that time, you are just not allowed to modify it.
It was observed that you can kinda modify the table though if you add new elements/the size of the table changes while its still creating the json string you will crash.

This function requires the luajit module to be enabled.

Arguments

1table tbl
The table to turn into json
2function callback

the callback that is called after it's done with the table

Function argument(s):
1string json - the final json

3boolean pretty
Make it a pretty json string