JSONFragmenter
Extracts portions of JSON (JavaScript Object Notation) formatted text into new FME features.
输出端口
For each newly created feature, the attribute identified by the结果属性parameter will contain JSON text referred to by the JSON query.
The json_type attribute will contain the JSON type of the text (object, array, string, etc) and the json_index parameter will contain the object key or array index of the JSON value.
如果 JSON query cannot be fully evaluated, a message will be logged, and the translation will continue.
If拒收不产生碎片特点设定为是, features that produce no fragments will be output through this port.
Features that could not be successfully processed will also be output through this port.Typically this happens when the attribute specified in the JSON Attribute parameter does not have a value, or has a value that is not valid JSON.
Parameters
Source
Allows for selecting between one of two options for JSON input:JSON属性要么文件/ URL
If selected, The JSON document can come from any string expression specified by an attribute value or a workspace parameter.
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.
Parameters
The JSON Query parameter is the JSON query referring to the JSON values which will become new FME features.
This parameter can be typed directly in the text box or, if reading JSON from a file or URL, by clicking the browse button that opens a dialog containing the structure of the JSON dataset in a tree form.Selecting a value from the tree will populate the parameter with the appropriate query string to turn the selected values into features.
A JSON query is a mechanism to refer to values inside JSON text.最外面的JSON值,它必须是一个对象或一个阵列时,总是由术语“JSON”提及。包含的值可以被称为使用JavaScript状括号指数运算符。在数组的值可以被称为使用其基于零的位置阵列中(例如,JSON [2]对于第三元件)。
在一个对象中的值可被称为使用其的对象的项名称。例如:
JSON [ “键”]
阵列中的全部或对象中的值可以被统称使用通配符索引。例如:
JSON [*]
使用该变压器可以具有多个表达式查询,分离由“+”运算。这使得变压器参考值的JSON文本的不同区域。例如:
JSON [ “resultSet_1”] [*] + JSON [ “resultSet_2”] [*]
见下面关于JSON查询的详细信息。
如果JSON文本是在以GeoJSON或EsriJSON格式,你可以选择片段格式至以GeoJSON要么ESRIJSON。这将通知JSONQueryFactory即以GeoJSON或ESRIJSON功能需要进行自动识别,并从查询结果中提取。
默认的格式,JSON,解析JSON文本为纯JSON。如果没有以GeoJSON或ESRIJSON特征构建中,将发出警告,并在文本将被视为纯JSON。
如果该参数是,其不产生碎片的特征将通过输出
如果JSONFragmenter被设定为从一个特征属性读JSON,然后输出被自动写入输入属性。然而,如果该JSONFragmenter被设定为从文件或URL读JSON,然后输出属性必须被选择。这是在做结果属性字段,它被激活时输入源设定为文件/ URL。输出属性可以从现有的输入属性,用户定义的参数来选择,或者一个新的属性也可以被创建。
Flattening Parameters
如果JSON查询产生JSON对象,该密钥可以用于通过设定为,以产生用于新的特征(一个或多个)附加的属性是。如果JSON查询产生JSON数组,和一个值被提供给前缀的新属性随着参数,列表属性将被创建,使用该前缀作为列表名称和JSON数组值作为列表元素。
注意:列表属性不从工作台的输出模式访问的,除非它们正在使用对它们进行操作的变压器,例如第一处理ListExploder要么ListConcatenator。或者,AttributeExposer可以使用。
当。。。的时候平展查询结果为属性参数设置为是时,该参数控制,其被创建的属性。如果它被设置为没有中,每个JSON对象键将成为一个属性和相应的JSON值将成为的属性值。如果这个参数设置为是中,只有对象其是简单类型(整数,字符串等)的值将成为的属性值,而嵌套对象和数组将递归地平坦化。
如果平展查询结果为属性参数设置为是中,前缀的新属性随着参数可以被用来提供一个字符串与前缀新创建的属性。如果所选择的格式为以GeoJSON或ESRIJSON,格式特定的键不会被添加作为属性,而是将通过适当的格式解析器进行处理。
公开任何属性,使他们能够通过其它变压器使用。直接在文本框中键入或单击浏览按钮来显示编辑和添加属性那里。
JSON Queries
A JSON query is a simple mechanism to refer to values within a JSON document.A query is made up of one or more expressions, which are separated by a + operator.There are three types of expressions: JSON structure expressions, JSON property expressions and string literal expressions.
JSON Structure Expressions
A JSON structure expression can refer to values in a JSON document.The outermost JSON element, which must be an array or an object, is always referred to by the term json, and this term must appear at the beginning of every JSON structure expression.The child elements can be referred to using JavaScript-like square bracket index operators.For example, if the outermost element is an array, the first element of the array can be referred to by the expression json[0], the second element can be referred to by the expression json[1], and so on.Likewise, if the outermost JSON element is an object, with keys "name" and "address", then the values of these keys can be referred to by the expressions json["name"] and json["address"] respectively.
These index operators can be cascaded.For example, it the outermost JSON element is an object with a key and "address" whose value is an object containing keys "city" and "province", then these values can be referred to by the expressions json["address"]["city"] and json["address"]["province"].
In order to refer to all of the values in an array or object, a wildcard index * can be used.For example, if the outermost JSON element is an array, then the expression json[*] refers to every element in the array.
JSON Property Expressions
A property expression is a structure expression as described above, followed by a .(dot) operator and a property name.Currently, the only supported properties are type and size.The type property returns the type of the JSON value referred to by the JSON structure expression.For example, if the outermost JSON element is an array, and the first element of the array is a string, then the expression json[0].type would have a value of string.The size property, which can only be applied to an array, returns the number of elements in the array.
String Literal Expressions
A string literal expression is simply a quoted string value, such as "this is a string literal expression".
FME Licensing Level
FME Professional edition and above
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
Search FME Community
Search for samples and information about this transformer on theFME Community。
Keywords: JSONExploder