XLSX Serialize/Deserialize
Posted: Sat Feb 11, 2023 12:50 pm
I try to convert a Json file into XLSX file, for to do this i create this simple function
I always get "Error serializing item!" error when a table is created from a json file.
This is a json that i need to convert:
Code: Select all
Function p_SaveXLSX()
Local f$ = moai.Get("file", "text")
Local mTable = {}
If f$ <>""
;convert json file into table
mTable = DeserializeTable(FileToString(f$), "Default")
;convert table into XLSX file
Local fname$ = UnleftStr(FilePart(f$), 5)..".xlsx"
Local s$ = FileRequest("Save XLSX", {Filters="xlsx", Mode=#REQ_SAVEMODE, File=fname$})
;StringToFile(SerializeTable(mTable, "xlsx"), s$)
OpenFile(1, s$, #MODE_WRITE)
WriteTable(1, mTable, {Adapter="xlsx"})
CloseFile(1)
EndIf
EndFunction
This is a json that i need to convert:
Code: Select all
{
"mod_name": "MOD Test 2020",
"mod_url": "http://filedn.eu/lM8guATtwL9pUR2zqpEfSVF/mod1/files",
"mod_version": "1.00",
"mod_date": "03/07/2020"
}