JSONFormatter
提供格式化JSON(JavaScript对象表示法)文本的选项。
输入端口
输入features that contain the JSON text attributes.
Output Ports
Features output through this port will contain formatted JSON text.
Parameters
输入Settings
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:
- Pretty Print: The JSON text will be formatted by adding indentations and new lines for improved readability.
- 线性化: 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 the线性化formatting type.
When this parameter is set toYes,格式化器将删除任何空字符串值。它不会删除仅包含空格的字符串。如果空字符串是对象值,则也将删除关联的对象键。不删除为对象键的空字符串。例如,假设以下对象是输入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 Values参数。也就是说,如果空字符串,空值或嵌套的空对象或阵列导致对象或数组变为空,则将删除。将不会删除根对象或数组,因此即使将此参数设置为,也可以是格式化器中的输出将是空对象或数组Yes. 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.
指定结果属性的字符编码。有效选项是UTF-8,UTF-16和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 attributes从工作台中的输出架构无法访问,除非首先使用在它们上操作的变压器处理它们,例如ListExploderorListConcatenator. All list attribute transformers are displayed in the Contents pane of the Transformer Help underLists. 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知识中心
搜索有关此变压器的样本和信息FME Knowledge Center.