FTL Native Messages to JSON Translation Reference

This section details the translation between fields in FTL messages and equivalent fields in the JSON representations used on the Apache Pulsar side of the Bridge for Apache Pulsar.

The Bridge for Apache Pulsar connectors can use this translation scheme in both directions to provide easy access to and control of message contents from either TIBCO FTL or Apache Pulsar.

Inbox

FTL inbox fields are not supported outside of FTL. The translation from FTL to JSON discards inbox fields.

Field Translations

The table juxtaposes the Java code fragment that would create an FTL message against the equivalent JSON representation.

FTL Message Field (Java) JSON Representation
message.setLong("my-long",1);
"my-long": 1
long[] longArray = {1, 2, 3};
message.setArray("my-long-array", longArray);
"my-long-array": [ 1, 2, 3 ]
message.setString("my-string", "hello");
"my-string": "hello"
String[] stringArray = {"eeny", "meeny", "miny"};
message.setArray("my-string-array", stringArray);
"my-string-array":
  [ "eeny", "meeny", "miny" ]
message.setDouble("my-double", 9.9);
"my-double": { "_d_": 9.9 }
Note: An FTL double field is represented as a JSON object with one field named "_d_". Its value must be either a JSON number, or one of the following special string values:
  • "Infinity" (positive infinity)
  • "-Infinity" (negative infinity)
  • "NaN" (not a number)
double[] doubleArray =
  {1.1,
   Double.POSITIVE_INFINITY,
   Double.NEGATIVE_INFINITY,
   Double.NaN};
message.setArray("my-double-array", doubleArray);
"my-double-array": [
  { "_d_": 1.1 },
  { "_d_": "Infinity" }, 
  { "_d_": "-Infinity" },
  { "_d_": "NaN" }
]
TibDateTime dateTime = new TibDateTime();
dateTime.set(443815200, 0); 
message.setDateTime("my-dateTime", dateTime);
"my-dateTime": {
   "_m_": 443815200000
}
Note: An FTL TibDateTime field is represented as a JSON object with one field named "_m_". Its value must be a JSON number, which represents the number of milliseconds since the UNIX Epoch.

The JSON representation excludes nanoseconds, truncating to the nearest millisecond.

TibDateTime dt1 = new TibDateTime();
dt1.set(1168365600, 0);
TibDateTime dt2 = new TibDateTime();
dt2.set(1003860000, 0);
TibDateTime dt3 = new TibDateTime();
dt3.set(1003860000, 0);
TibDateTime[] dateTimeArray = {dt1, dt2, dt3};
message.setArray("my-dateTime-array", dateTimeArray);
"my-dateTime-array": [
  { "_m_": 1168365600000 },
  { "_m_": 1003860000000 }, 
  { "_m_": 1003860000000 } 
]
byte[] opaque = {'H', 'i'};
message.setOpaque("my-opaque", opaque);
"my-opaque": {
  "_o_": "SGk=" }
Note: An FTL opaque field is represented as a JSON object with one field named "_o_". Its value is a JSON string containing base64-encoded binary data.
Message nestedMessage = realm.createMessage(null);
nestedMessage.setLong("my-nested-message-long", 2);
message.setMessage("my-message", nestedMessage);
 "my-message": {
  "my-nested-message-long": 2 }
Note: A nested FTL message field is represented as a nested JSON object using the same JSON representation as any other FTL message.
Message m1 = realm.createMessage(null);
m1.setString("m1-string", "ftl-is-great");
Message m2 = rlm.createMessage(null);
m2.setDouble("m2-double", 4.5);
Message m3 = rlm.createMessage(null);
m3.setLong("m3-long", 3);
Message[] messageArray = {m1, m2, m3};
message.setArray("my-message-array", messageArray);
 "my-message-array": [
  { "m1-string": "ftl-is-great" },
  { "m2-double":
      { "_d_": 4.5 } },
  { "m3-long": 3 }
]