String indexes, spaces, and WriteTable()
Posted: Mon Nov 17, 2025 10:53 pm
I have a table with string indexes, and the strings come from outside the program and may also contain spaces. Now I wanted to write this table using WriteTable(), but this did not work.
The following example works with the legacy serializer, but with Adapter="Default" I get an “Error serializing item!” message. With the real strings in my program the legacy serializer stops at some of it with "Could not read all characters from file!", maybe other characters make problems too.
I know that spaces in the index also cause trouble elsewhere, because the dot syntax variant doesn't work with them either, but I wanted to report this anyway.
I see a solution in converting the strings to a hexadecimal representation or something similar or a MD5 hash, but perhaps there is an easier way.
The following example works with the legacy serializer, but with Adapter="Default" I get an “Error serializing item!” message. With the real strings in my program the legacy serializer stops at some of it with "Could not read all characters from file!", maybe other characters make problems too.
I know that spaces in the index also cause trouble elsewhere, because the dot syntax variant doesn't work with them either, but I wanted to report this anyway.
I see a solution in converting the strings to a hexadecimal representation or something similar or a MD5 hash, but perhaps there is an easier way.
Code: Select all
testtable={["a b"] = 1}
DebugPrint(testtable["a b"])
OpenFile(1, "test.json", #MODE_WRITE)
WriteTable(1, testtable, {Adapter = "Default"})
CloseFile(1)