Merge pull request #689 from argonui/json-decoding

Added regular JSON parser as fallback
This commit is contained in:
dscarpac 2024-05-26 06:18:46 -05:00 committed by GitHub
commit 794949fdc6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -116,7 +116,14 @@ end
---@param cardData table TTS object data for the card
function addCardToIndex(cardData)
-- using the more efficient 'json.parse()' to speed this process up
local cardMetadata = json.parse(cardData.GMNotes)
local status, cardMetadata = pcall(function() json.parse(cardData.GMNotes) end)
-- if an error happens, fallback to the regular parser
if status ~= true then
cardMetadata = JSON.decode(cardData.GMNotes)
end
-- if metadata was not valid JSON or empty, don't add the card
if not cardMetadata then return end
-- use the ZoopGuid as fallback if no id present