diff options
author | Mark Pulford <mark@kyne.com.au> | 2011-08-10 14:09:52 +0400 |
---|---|---|
committer | Mark Pulford <mark@kyne.com.au> | 2011-08-10 14:09:52 +0400 |
commit | 386fdad6820fefa77355ed330f3072a5e2a4bd3e (patch) | |
tree | 2b72bae1be543dc1116eb512d50f1fa5731ed44e /tests | |
parent | e5ee37f77f029f4df68a0fc92fc7a79c9f8af210 (diff) |
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 <agentzh@gmail.com>
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test.lua | 5 |
1 files changed, 3 insertions, 2 deletions
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)" } }, |