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:
+3
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user