Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Komag
Roku Guru

BUG - case sensitivity in AA.Delete() - solved, ParseJson()

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!
0 Kudos
6 REPLIES 6
NewManLiving
Visitor

Re: BUG - case sensitivity in AA.Delete()

What happens when you call setmodecasesensitive
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
RokuMarkn
Visitor

Re: BUG - case sensitivity in AA.Delete()

Are you calling SetModeCaseSensitive on the AA? If you don't call that, it should work the way you want:


BrightScript Debugger> a={}
BrightScript Debugger> a.teleTrap = 1
BrightScript Debugger> ?a.Delete("teleTrap")
true


--Mark
0 Kudos
Komag
Roku Guru

Re: BUG - case sensitivity in AA.Delete()

No, I've never called SetModeCaseSensitive in my life! 8-)

When I try your test in debugger it works just like you show it working for you.

So something must be different...testing...
0 Kudos
Komag
Roku Guru

Re: BUG - case sensitivity in AA.Delete()

AHA! I found the answer! 😄

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.
0 Kudos
EnTerr
Roku Guru

Re: BUG - case sensitivity in AA.Delete() - solved, ParseJso

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
0 Kudos
Komag
Roku Guru

Re: BUG - case sensitivity in AA.Delete() - solved, ParseJso

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! 8-)
0 Kudos