From c2aad59ba6b52ccc9f1547f12e22c7c15f465909 Mon Sep 17 00:00:00 2001
From: luistung <dongliang1986@gmail.com>
Date: Thu, 22 Sep 2022 18:50:22 +0800
Subject: [PATCH] Update json.lua

add a dummy key { _ = false } to force empty table to be encoded to as an object
---
 json.lua | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/json.lua b/json.lua
index 711ef78..776f5ec 100644
--- a/json.lua
+++ b/json.lua
@@ -90,7 +90,9 @@ local function encode_table(val, stack)
       if type(k) ~= "string" then
         error("invalid table: mixed or invalid key types")
       end
-      table.insert(res, encode(k, stack) .. ":" .. encode(v, stack))
+      if k ~= "_" then
+        table.insert(res, encode(k, stack) .. ":" .. encode(v, stack))
+      end
     end
     stack[val] = nil
     return "{" .. table.concat(res, ",") .. "}"