JSONFormatter
Provides options for formatting JSON (JavaScript Object Notation) text.
Input Ports
Input features that contain the JSON text attributes.
Output Ports
Features output through this port will contain formatted JSON text.
Parameters
Input Settings
Specifies the attribute containing the JSON text which is to be formatted.
Format Settings
Select the desired formatting of the JSON text:
- Pretty Print: The JSON text will be formatted by adding indentations and new lines for improved readability.
- Linearize: All JSON contents will be put on a single line, to reduce the size 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:
[]
Output Settings
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.
Editing Transformer Parameters
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.
Transformer Categories
FME Licensing Level
FME Professional edition and above
Search FME Knowledge Center
Search for samples and information about this transformer on the FME Knowledge Center.