Closed JimmyCushnie closed 5 years ago
Alternatively you could allow the use of double quotes on keys, which would be ignored when deserializing. So "-100"
would be deserialized as -100
, and not confused with a list as it doesn't begin with -
.
That's a really good idea. Perhaps dictionary keys should always have quotes around them, to prevent any unforeseen issues like this cropping up later.
That works. It would also be great if you could escape the quotes with \", so that the string can contain quotes.
Strings can already contain quotes. If you want to serialize "hello"
, it is stored in the file as ""hello""
.
Fixed in 2487cce
and will be in the next release. Dictionaries, when serialized with their keys as children, will always surround the keys in quotes.
In 4934481
I fixed this in a much nicer way. Dictionaries now check if their key is a valid SUCC key, and if not, they serialize as an array of KeyValuePair.
That code generates this file:
Notice the key called "-100". Keys are not allowed to begin with
-
, as that character is reserved for list nodes. Trying to read the file later will throw errors. This can also happen when using DataFile.SaveAsDictionary().The solution is probably to allow
-
in key nodes, and determine what is a list node by the absence of:
.