I have a function that sets a new associative array (AA) value: m.cAA.puz[ 1].teleTrap = 1 ’ Store puz info
Later I wanted to delete it, so I ran: ? m.cAA.puz[ 1].Delete(“teleTrap”) ’ Reset to default where key/value doesn’t exist, potentially cuts down on save game size
But it wasn’t working - which is why I added the ?, and it always prints “false” - why???
Then I tried: ? m.cAA.puz[ 1].Delete(“teletrap”) ’ Reset to default where key/value doesn’t exist, potentially cuts down on save game size
WORKS!
Turns out when I assigned the value, it was assigned as “teletrap” all lower case, and when I go to use .Delete(), it’s case sensitive! This seems like a bug to me. I don’t care if it saves the key string all lower case even though I entered some caps, but I wanna have my cake and eat it too - allow the delete command to not care if I enter caps there too!
I was also testing my saving and loading using registry info. I do that via FormatJson() and ParseJson(), so I just reviewed them and see “Any roAssociativeArray objects in the returned objects will be case sensitive”. So that explains it!
I suppose it’s not a bug then, just something to be aware of.
Yep, it’s a feature necessitated by JSON being case-sensitive itself. If regular case-insensitive AAs were returned, that will risk “folding” multiple elements into one, like say for “{a: 97, A: 65}”. So the parser creates all its AAs case-sensitive
Got it. I have no experience with Json (not a programmer), but that makes sense.
BTW, I was ECSTATIC to discover FormatJson() and ParseJson(), makes my life 100 times easier than saving and loading a zillion bits of data into individual registry entries!