Fix JSON encoding: force empty tables to encode as arrays

Lua's json.encode produces {} for empty tables instead of [].
Use json.util.InitArray to mark tables as arrays so they encode
correctly as [] for authors, bookmarks, highlights, notes, and books.
This commit is contained in:
2026-05-30 10:24:56 -04:00
parent ac84585e50
commit 618793a075
2 changed files with 8 additions and 4 deletions
+3 -1
View File
@@ -1,4 +1,5 @@
local json = require("json")
local json_util = require("json/util")
local logger = require("logger")
local ltn12 = require("ltn12")
local socketutil = require("socketutil")
@@ -118,8 +119,9 @@ function BookhoardAPI:checkRegistrationStatus(registration_id)
end
function BookhoardAPI:syncProgress(book_data, sync_mode)
local books = json_util.InitArray({ book_data })
return self:_request("POST", "/api/sync/koreader/progress", {
books = { book_data },
books = books,
sync_mode = sync_mode or "immediate",
}, PROGRESS_TIMEOUTS)
end