Tip: Native case-sensitive Dictionary

A JSONItem should be Case Sensitive by now since the JSON spec says so.
Perhaps it can be converted back to a dictionary ?

Notes (from the docs):
http://documentation.xojo.com/api/text/json/jsonitem.html

Names must be Strings, must be unique within an object and are case-sensitive.

Inspired by @Kem_Tekinay, I have written my own API 2.0 dictionary replacement called BetterDictionary that can be case sensitive or case insensitive (set at instantiation). You can find it within my (new) Xojo-Collections repo.

It has the added advantage that it allows you to mix and match String and Text keys whilst considering them equivalent. I needed this as my current project uses Text throughout and I kept getting caught out by the fact that there is no way in the IDE to write a Text literal. It essentially works around this “bug”:

Var t As Text = "key1"
Var d As New Dictionary("key1" : Nil)

If d.HasKey(t) Then
  Break // Never gets here but the code reads like it should.
Else
  Break
End If
2 Likes