use TestLua; plan tests => 2 * blocks(); run_tests(); __DATA__ === TEST 1: empty tables as objects --- lua local cjson = require "cjson" print(cjson.encode({})) print(cjson.encode({dogs = {}})) --- out {} {"dogs":{}} === TEST 2: empty tables as arrays --- lua local cjson = require "cjson" cjson.encode_empty_table_as_object(false) print(cjson.encode({})) print(cjson.encode({dogs = {}})) --- out [] {"dogs":[]} === TEST 3: empty tables as objects (explicit) --- lua local cjson = require "cjson" cjson.encode_empty_table_as_object(true) print(cjson.encode({})) print(cjson.encode({dogs = {}})) --- out {} {"dogs":{}}