Product Documentation

MQTT V3 Plug-in Reference

Previous Topic

Next Topic

"fieldFormat"

  • String
  • Defaults to ""
  • Optional

"fieldFormat" allows specialized data types to be embedded in string format in a table field.

It specifies how to convert specific MQTT data into a string format so it can be stored in a string-based table field.

It applies only when "fieldType" is "CHAR", "NCHAR", "VARCHAR", "NVARCHAR", and "LVARCHAR".

Valid field formats are:

"stringify”

"stringify" converts the value of a JSON property into a string. It extracts the entire JSON subdocument starting at "propertyPath" and stores it in a table field as a JSON string. It converts JSON arrays, arrays of objects, and objects into string fields. The conversion follows the rules of the JavaScript function JSON.stringify(), which is the inverse of JSON.parse().

Example 1

Configuration Message:

{

"operation": "CreatePersistenceTopic",

"persistenceTopic": "myTopic",

"tableName": "table1",

"mapOfPropertiesToFields":

[

{

"propertyPath": "myArray",

"fieldName": "myField1",

"fieldType": "VARCHAR",

"fieldFormat": "stringify"

}

]

}

Data Message:

{

"myArray": [0, null, 2, -3.3, true, 5, "six", false]

}

Resulting record in table1:

myField1

[0,null,2,-3.3,true,5,"six",false]

Example 2

Configuration Message:

{

"operation": "CreatePersistenceTopic",

"persistenceTopic": "myTopic",

"tableName": "table1",

"mapOfPropertiesToFields":

[

{

"propertyPath": "myObject",

"fieldName": "myField1",

"fieldType": "VARCHAR",

"fieldFormat": "stringify"

}

]

}

Data Message:

{

"myObject": { "prop1": 1, "prop2": [0,1,2] },

"myProp3": 3

}

Resulting record in table1:

myField1

{"prop1":1,"prop2":[0,1,2]}

TOCIndex