From e792cd0336219d71161a805bbde2889ea6883d0a Mon Sep 17 00:00:00 2001 From: spiiin Date: Sun, 22 Apr 2018 21:14:10 +0300 Subject: [PATCH] compatibility with lua 5.1 (in lua 5.1 -> tostring(val, stack) returns tostring(val)..tostring(stack), but in lua>5.1 it returns just tostring(val). --- json.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/json.lua b/json.lua index a3d7530..6c09c91 100644 --- a/json.lua +++ b/json.lua @@ -111,13 +111,17 @@ local function encode_number(val) return string.format("%.14g", val) end +local function encode_bool(val) + return tostring(val) +end + local type_func_map = { [ "nil" ] = encode_nil, [ "table" ] = encode_table, [ "string" ] = encode_string, [ "number" ] = encode_number, - [ "boolean" ] = tostring, + [ "boolean" ] = encode_bool, }