summaryrefslogtreecommitdiffhomepage
path: root/libs/luci-lib-jsonc/src
AgeCommit message (Collapse)Author
2023-10-25luci-lib-jsonc: improve handling of integral numeric valuesJo-Philipp Wich
Properly deal with integral numeric values exceeding the int32_t range by replacing the cast logic with more fine grained checks: - Lua numbers which are integers in the first place are directly converted to JSON integers - Finite double Lua numbers which are integral are converted to JSON integer values - All other numeric values are converted to JSON doubles This should bring the handling of large integral value in line with the documented behavior of turning non-fractional Lua numbers into JSON integers. Fixes: #6647 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-03-20luci-lib-jsonc: stringify int use json_object_new_int64 insteadJustin Klaassen
Fixes: #3293 Signed-off-by: Justin Klaassen <jck112@users.noreply.github.com>
2019-11-13luci-lib-jsonc: store large JSON integer values as Lua doublesJo-Philipp Wich
Fixes: #3293 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
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>