JSONFormatter
Provides options for formatting JSON (JavaScript Object Notation) text.
输入端口
Input features that contain the JSON text attributes.
输出的几率ts
Features output through this port will contain formatted JSON text.
Parameters
Source
Allows for selecting between one of two options for JSON input:JSON DocumentorFile/URL
If selected, The JSON document can come from any string expression, including attribute values and workspace parameters.
If selected, the JSON source can be read from a local file at a specified file path, or from the internet at a specified URL.
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 thePretty Printformatting 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 theLinearizeformatting type.
When this parameter is set toYes, 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 theRemove Empty Stringsoption, except that it applies to null values.When it is set toYes, 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 toYes, the formatter will remove any empty objects or arrays from the input JSON.This is applied recursively in conjunction with theRemove Empty StringsandRemove Null Valuesparameters.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 toYes.For example, suppose the following JSON object is the input to the formatter, and both theRemove Empty StringsandRemove Null Valuesparameters are set toYes.
[
[],
{},
[ 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.
Name of the list attribute that contains information on JSON validation errors.The features that exit the transformer through the
- Error description
- Line number where the error occurred
- Column number where the error occurred
- Error type/severity
Note:List attributesare not accessible from the output schema in Workbench unless they are first processed using a transformer that operates on them, such asListExploderorListConcatenator.Alternatively,AttributeExposercan be used.
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, clickbeside the applicable parameter.For more information, seeTransformer Parameter Menu Options.
Transformer Categories
FME Licensing Level
FME Professional edition and above
FME Community
The FME Community is the place for demos, how-tos, articles, FAQs, and more.Get answers to your questions, learn from other users, and suggest, vote, and comment on new features.
Search for samples and information about this transformer on theFME Community.