Provides options for formatting JSON (JavaScript Object Notation) text.
Input features that contain the JSON text attributes.
Features output through this port will contain formatted JSON text.
Features with an invalid JSON document are output through this port.
The source JSON document. The JSON document can come from any string expression, including attribute values and workspace parameters.
Select the desired formatting of the JSON text:
When using the Pretty Print formatting type, this option may be used to control the indent style of the formatted JSON text. Each indent may be a tab or 1-8 space characters. This parameter is disabled when using the Linearize formatting type.
When this parameter is set to Yes, the formatter will remove any empty string values. It will not remove strings which contain only whitespace. If the empty string is an object value, the associated object key will also be removed. Empty strings which are object keys will not be removed. For example, suppose the following object is the input JSON:
{
"key1" : "",
"key2" : " ",
"key3" : [""]
}
The output from the transformer will be:
{
"key2" : " ",
"key3" : []
}
This option is similar to the Remove Empty Strings option, except that it applies to null values. When it is set to Yes, the formatter will remove any nulls in the input JSON. If the null is an object value, the associated object key will also be removed. For example, suppose the following array is the input JSON:
[
null,
{
"key1" : null,
"key2" : "a value"
}
]
The output from the transformer will be:
[
{
"key2" : "a value"
}
]
When this parameter is set to Yes, the formatter will remove any empty objects or arrays from the input JSON. This is applied recursively in conjunction with the Remove Empty Strings and Remove Null Values parameters. That is, if empty strings, null values or nested empty objects or arrays cause an object or array to become empty, it will be removed. The root object or array will not be removed, so it is possible that the output from the formatter will be an empty object or array even if this parameter is set to Yes. For example, suppose the following JSON object is the input to the formatter, and both the Remove Empty Strings and Remove Null Values parameters are set to Yes.
[
[],
{},
[ null, "" ],
{
"key1" : "",
"key2" : null,
"key3" : []
}
]
The output from the formatter will be:
[]
Specifies the attribute which will contain the formatted JSON text.
Specifies the character encoding for the result attribute. Valid options are UTF-8, UTF-16 and UTF-32.
Name of the list attribute that contains information on JSON validation errors. The features that exit the transformer through the <Rejected> output port will have validation errors listed in this list attribute. Each validation error message is made up of four parts:
Note: List attributes are not accessible from the output schema in Workbench unless they are first processed using a transformer that operates on them, such as ListExploder or ListConcatenator. All list attribute transformers are displayed in the Contents pane of the Transformer Help under Lists. Alternatively, AttributeExposer can be used.
Using a set of menu options, transformer parameters can be assigned by referencing other elements in the workspace. More advanced functions, such as an advanced editor and an arithmetic editor, are also available in some transformers. To access a menu of these options, click beside the applicable parameter. For more information, see Transformer Parameter Menu Options.
FME Professional edition and above
Associated FME function or factory: JSONFormatterFactory
Search for samples and information about this transformer on the FME Knowledge Center.