Skip to content

My Favorite New Xojo Framework Features

The first classes in the new Xojo Framework have been available for all project types since Xojo 2015 Release 2. Here are some of my favorite features.


The new Text data type is a substitute for String and has the benefit of making encodings easier to work with. Essentially if you use Text, you don’t have to worry about the encoding. When you get data from an outside source (a file, a database or even a String), you specify the encoding so it can be stored as Text. Once it is in Text, you don’t worry about the encoding. When you need to send the Text to a file, DB or elsewhere, you convert it to data using whatever encoding is appropriate- usually UTF8.

You can easily use Text with your existing projects as a Text value converts back to a String automatically. For example, you can set a button Caption using a Text variable:

Dim t As Text = "Hello"
MyButton.Caption = t // converts automatically to String

If you have a String (such as a property of a UI control) you can easily convert it to Text by calling the ToText method. For example, you store the Caption of a button as Text:

Dim t As Text = MyButton.Caption.ToText


I prefer Xojo.Core.Dictionary because it is has an easy-to-use iterator, making it crazy-simply to loop through the items in the Dictionary:

Dim myDictionary As New Xojo.Core.Dictionary
myDictionary.Value("Name") = "Bob Roberts"
myDictionary.Value("City") = "Boston"
For Each entry As Xojo.Core.DictionaryEntry In myDictionary
  Dim key As Text = entry.Key
  Dim value As Text = entry.Value

Xojo.Core.Dictionary can also be case-sensitive which is not even an option with the classic Dicitonary class! You just have to subclass (or use AddHandler) and implement the CompareKeys event handler:

Dim leftText As Text = lhs
Dim rightText As Text = rhs
Return leftText.Compare(rightText, Text.CompareCaseSensitive)


In the new framework, JSON is handled by two methods (Xojo.Data.ParseJSON and Xojo.Data.GenerateJSON), typically with Xojo.Core.Dictionary. Creating JSON text from a Dictionary is one line of code:

Dim jsonText As Text = Xojo.Data.GenerateJSON(myDictionary)

And converting JSON text to a Dictionary is also one line of code:

Dim jsonDict As Xojo.Core.Dictionary = Xojo.Data.ParseJSON(jsonText)

Both of these methods are much faster than using JSONItem in the classic framework.


Xojo.Net.HTTPSocket uses HTTP 1.1. This is a big advantage over the classic HTTPSocket which only supports HTTP 1.0 making it not always compatible with some sites.

I recently did a webinar that shows how to use HTTPSocket with a variety of web services.


Lastly, I often work with Text files which means I have to deal with encodings. The TextInputStream and TextOutputStream make it easy to deal with encodings because the encoding is part of the method calls.

You can even use these classes with classic FolderItems by first converting them to Xojo.IO.FolderItem. For example, this prompts the user for a file and then opens it using a TextInputStream:

Dim f As FolderItem = GetOpenFolderItem("")
If f <> Nil Then
  Dim openFile As New Xojo.IO.FolderItem(f.NativePath.ToText)
  Dim input As Xojo.IO.TextInputStream
  input = Xojo.IO.TextInputStream.Open(openFile, Xojo.Core.TextEncoding.UTF8)
End If

If you have not already, try these new Xojo Framework classes in your projects. You’ll appreciate it!

Update (June 2020):

Since this was posted, there have been many updates to Xojo. In particular you should check out these equivalent API 2.0 features: