summaryrefslogtreecommitdiffhomepage
path: root/libs/luci-lib-jsonc
AgeCommit message (Collapse)Author
2018-12-21luci-lib-jsonc: prevent infinite recursion in stringifyJo-Philipp Wich
Also increase the stack size as needed to prevent crashes when serializing deeply nested tables. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2015-09-04luci-lib-jsonc: Add ltn12-compatible sink factoryJan-Philipp Litza
To use the luci-lib-jsonc parser as sink for an ltn12 pump (for example from stdin), the following code will now do: require 'luci.ltn12' require 'luci.jsonc' local parser = luci.jsonc.new() luci.ltn12.pump.all(luci.ltn12.source.file(io.input()), parser:sink()) print(parser:get()) Signed-off-by: Jan-Philipp Litza <janphilipp@litza.de>
2015-08-31luci-lib-jsonc: Fix memory leak in stringify()Jan-Philipp Litza
2015-08-30luci-lib-jsonc: allow encoding empty listsJan-Philipp Litza
To be consistent with the behavior of luci-lib-json, an empty Lua table should be encoded to an empty JSON list, not an empty JSON object. To still allow encoding empty JSON objects, the usage of anything other than a number or a string as a key (for example an empty table or a function) can be used to force encoding as an object: json.stringify({}) -- "[]" json.stringify({[{}] = true}) -- "{}" Signed-off-by: Jan-Philipp Litza <janphilipp@litza.de>
2015-08-30luci-lib-jsonc: Ignore non-string-or-number keys in tablesJan-Philipp Litza
Previously, the following caused a segmentation fault: json.stringify({[{}] = true}) This was caused by lua_tostring() returning NULL for anything but strings and numbers, letting json_object_object_add crash. This patch makes jsonc ignore all keys which have no string representation altogether. Signed-off-by: Jan-Philipp Litza <janphilipp@litza.de>
2015-01-28luci-lib-jsonc: add api documentationJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-26libs: add luci-lib-jsonc, a Lua binding for JSON-CJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>