Skip to content

Transitional JSON Interface for Scripting ​

As part of the change from Flow to Statelake, we have updated the JSON libraries in use. This has many benefits in speed and functionality, but it has changed the objects and interfaces when using JSON in scripting.

This means that when converting scripts from Flow to Statelake there are two approaches you can use:

  1. Rewrite your scripts using the new interfaces.
  2. Use the transitional interfaces so that existing scripts can run with minimal logic changes.

It is strongly recommended that you do not use the transitional scripting interfaces for any new JSON scripting.

When to rewrite your scriptsWhen to use the transitional interfaces
You have a small number of scripts to migrateYou have a large number of scripts to migrate
You want to take advantage of improved and simpler interfaces that will continue to be improved and extended in the future.You need to migrate to Statelake in a very short amount of time or with minimal code review

The new scripting interfaces are documented elsewhere, but below is a guide to the transitional interfaces.

Guide to converting legacy scripts to Transitional JSON Classes ​

The transitional classes create wrappers around the new JSON object model in Statelake to allow the new classes to behave like the old ones. Transitional classes include Flw in their name.

WARNING

When converting a script you should convert to EITHER transitional classes or the new Statelake JSON classes (which have the same names as the legacy Flow classes).

Do not mix the two class models in your scripts.

Flow JSON ClassStatelake Transitional JSON ClassNotes
TJSONValueTFlwJSONValue
TJSONTextNo direct equivalent, replace with TFlwJSONValue
TJSONObjectTFlwJSONObject
TJSONArrayTFlwJSONArray

Transitional JSON Classes ​

Class Function: TryCreateFlwJSON ​

NameParametersData TypeNotes
TryCreateFlwJSONaString: StringTFlwJSONValueParses aString and returns a TFlwJSONValue which could by of any type or will be nil if parsing failed.

Class: TFlwJSONValue ​

Properties
NameData TypeNotes
AsArrayTFlwJSONArray
AsObjectTFlwJSONObject
AsTextTFlwJSONValue
ValueTypeReturns the enumerated type of the valueOne of:
- jsString
- jsNumber
- jsBoolean
- jsArray
- jsObject
- jsNull
AsBooleanBoolean
AsDateTimeTDateTime
AsDoubleDouble
AsGUIDTGUID
AsInt64Int64
AsStringString
IsNullBoolean
NameStringReturns the name of the object
AsDisplayTextStringReturns formatted JSON
Methods
NameParametersData TypeNotes
CreateFromStreamaStream: TStreamTFlwJSONValue
CreateFromStringaString: StringTFlwJSONValue
LoadFromFileaFileName: String
LoadFromStreamaStream: TStream
SaveToFileaFileName: String
aCompact: Boolean
If aCompact is false then output is formatted with whitespace
SaveToStreamaStream: TStream
aCompact: Boolean
If aCompact is false then output is formatted with whitespace
FreeFrees the object and all of it’s children. Must be called on the root JSON object to avoid memory leaks.

Class: TFlwJSONObject ​

Constructors
NameParametersData TypeNotes
CreateTFlwJSONObjectCreates an empty object
CreateFromStringaString: StringTFlwJSONObjectCreates an object with contents parsed from aString
Properties
NameData TypeNotes
ValueCountInteger
ValuesTFlwJSONValueAllows access by child name eg:
obj['child_name']
ValueByIndexTFlwJSONValueAllows access by child index from zero eg:
obj[3]
AsStringString
IsNullBoolean
NameStringReturns the name of the object
AsDisplayTextStringReturns formatted JSON
Methods
NameParametersData TypeNotes
AddBooleanaName: String
aValue: Boolean
AddDateTimeaName: String
aValue: TDateTime
AddDoubleaName: String
aValue: Double
AddGUIDaName: String
aValue: TGUID
AddIntegeraName: String
aValue: Integer
AddNullaName: String
AddStringaName: String
aValue: String
AddArrayaName: StringTFlwJSONArray
AddObjectaName: StringTFlwJSONObject
ContainsaValueName: StringBoolean
DeleteaName: String
DeleteByIndexaIndex: Integer
FindValueaName:StringTFlwJSONValue
LoadFromStreamaStream: TStream
OptBooleanaName:String
aDefault: Boolean
BooleanReturns the value identified by aName. If it is not found, returns aDefault.
OptDateTimeaName:String
aDefault: TDateTime
TDateTimeReturns the value identified by aName. If it is not found, returns aDefault.
OptDoubleaName:String
aDefault: Double
DoubleReturns the value identified by aName. If it is not found, returns aDefault.
OptIntegeraName:String
aDefault: Integer
IntegerReturns the value identified by aName. If it is not found, returns aDefault.
OptStringaName:String
aDefault: String
StringReturns the value identified by aName. If it is not found, returns aDefault.
FreeFrees the object and all of it’s children. Must be called on the root JSON object to avoid memory leaks.

Class: TFlwJSONArray ​

Constructors
NameParametersData TypeNotes
CreateTFlwJSONArrayCreates an empty object
Properties
NameData TypeNotes
CountInteger
ItemsTFlwJSONValueAllows access by child index from zero eg:
arr[3]
AsStringString
IsNullBoolean
NameStringReturns the name of the object
AsDisplayTextStringReturns formatted JSON
Methods
NameParametersData TypeNotes
AddBooleanaValue: Boolean
AddDateTimeaValue: TDateTime
AddDoubleaValue: Double
AddGUIDaValue: TGUID
AddIntegeraValue: Integer
AddNull
AddStringaValue: String
AddArrayTFlwJSONArray
AddObjectTFlwJSONObject
DeleteaIndex: Integer
FreeFrees the object and all of it’s children. Must be called on the root JSON object to avoid memory leaks.