A Xojo module for encoding and decoding objects for storage and transmission using JSON.

EncodeKit exposes two classes: JSONEncoder and JSONDecoder which are capable of serialising and deserialising almost any Xojo class with little or no input from you.




Firstly, drop the EncodeKit module into your project.

Before you can encode a custom class, you must first register it with EncodeKit. There is no need to register Xojo primitives or other common built-in classes such as Dictionary, FolderItem and DateTime as they are handled internally.

To register a class called MyClass:

EncodeKit.RegisterClass GetTypeInfo(MyClass)

To encode an instance of MyClass:

Var encoder As New EncodeKit.JSONEncoder
Var c1 As New MyClass
Var json As String = encoder.Encode(c1)

To decode an instance of MyClass:

Var decoder As New EncodeKit.JSONDecoder
Var c1 As MyClass = decoder.Decode(json)


This is essentially a modern port of Kem Tekinay's proof-of-concept Serializer_MTC class.

EncodeKit differs from that project in the following ways:

  1. Separate encoder and decoder classes.
  2. API 2.0.
  3. Removed all references to Xojo.Data and Xojo.Core namespaces.
  4. Removed the need for Text and Auto datatypes.
  5. Removed support for Date.
  6. Added support for DateTime, TimeZone and FolderItem encoding.