From 386fdad6820fefa77355ed330f3072a5e2a4bd3e Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Wed, 10 Aug 2011 19:39:52 +0930 Subject: Fix detection of objects with numeric string keys lua_array_length() recognised some objects with numeric string keys as arrays since it was incorrectly using lua_isnumber(). When an object was incorrectly recognised as an array, json_append_array() would not find any entries and generate a result like: [null,null,...] Reported by: Zhang "agentzh" Yichun --- tests/test.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test.lua b/tests/test.lua index 7a9b0ff..7a75243 100755 --- a/tests/test.lua +++ b/tests/test.lua @@ -118,13 +118,14 @@ local encode_table_tests = { end, { json.encode, { { [3] = "sparse test" } }, true, { '[null,null,"sparse test"]' } }, - { json.encode, { { [1] = "one", [4] = "sparse test" } }, true, { '["one",null,null,"sparse test"]' } }, - { json.encode, { { [1] = "one", [5] = "sparse test" } }, true, { '{"1":"one","5":"sparse test"}' } }, + { json.encode, { { ["2"] = "numeric string key test" } }, + true, { '{"2":"numeric string key test"}' } }, + { json.encode, { nested5 }, true, { '[[[[["nested"]]]]]' } }, { json.encode, { { nested5 } }, false, { "Cannot serialise, excessive nesting (6)" } }, -- cgit v1.2.3-55-g6feb