JSONFragmenter
Extracts portions of JSON (JavaScript Object Notation) formatted text into new FME features.
Output Ports
为每个新创建的特性,the attribute identified by the输出属性参数将包含JSON查询所引用的JSON文本。
json_type属性将包含文本的json类型(对象,数组,字符串,etc) and the json_index parameter will contain the object key or array index of the JSON value.
If the JSON query cannot be fully evaluated,将记录一条消息,and the translation will continue.
Parameters
The source JSON document.The JSON document can come from any string expression,包括属性值和工作区参数。
The JSON Query parameter is the JSON query referring to the JSON values which will become new FME features.
A JSON query is a mechanism to refer to values inside JSON text.最外层的json值,which must be an object or an array,is always referred to by the term "json".所包含的值可以使用类似于javascript的方括号索引运算符来引用。数组中的值可以使用其在数组中基于零的位置来引用(例如,json[2]用于第三个元素)。
对象中的值可以使用其对象键名称来引用。例如:
json["key"]
All of the values in an array or object can be referred to collectively using a wildcard index.For example:
json[*]
The query used by this transformer can have multiple expressions,separated by a '+' operator.This allows the transformer to refer to values in different areas of the JSON text.For example:
json["resultSet_1"][*] + json["resultSet_2"][*]
有关JSON查询的更多信息,请参见下面的内容。
Name of the attribute that contains the JSON fragment.
Flattening Parameters
如果json查询生成一个json对象,通过将设置为,键可用于为新功能生成其他属性。Yes.If the JSON query produces a JSON array,并向Prefix New Attributes Withparameter,a list attribute will be created,using the prefix as the list name,以及作为列表元素的JSON数组值。
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.All list attribute transformers are displayed in the Contents pane of the Transformer Help underLists.或者,AttributeExposercan be used.
When the ‘Load Keys as Attributes' parameter is set to ‘Yes',此参数控制创建的属性。If it is set to ‘No',each JSON object key will become an attribute and the corresponding JSON value will become the attribute value.If this parameter is set to ‘Yes',only object values which are simple types (integers,串,etc) will become attribute values,而嵌套的对象和数组将被递归地展平。
If the ‘Load Keys as Attributes' parameter is set to ‘Yes',the ‘Prefix New Attributes With' parameter may be used to provide a string with which to prefix the newly-created attributes.If the selected format is GeoJSON or ESRIJSON,特定于格式的键不会作为属性添加,but will instead be handled by the appropriate format parser.
Exposes any attributes so they can be used by other transformers.直接在文本框中键入或单击“浏览”按钮以显示编辑器并在其中添加属性。
JSON Queries
A JSON query is a simple mechanism to refer to values within a JSON document.一个查询是由一个或多个表达式,由+运算符分隔。There are three types of expressions: JSON structure expressions,JSON property expressions and string literal expressions.
JSON Structure Expressions
JSON结构表达式可以引用JSON文档中的值。The outermost JSON element,which must be an array or an object,总是用术语json来指代,and this term must appear at the beginning of every JSON structure expression.可以使用类似于javascript的方括号索引运算符来引用子元素。例如,如果最外面的元素是数组,the first element of the array can be referred to by the expression json[0],第二个元素可以由表达式json[1]引用,and so on.同样地,如果最外层的json元素是一个对象,用“name”和“address”键,然后,这些键的值可以分别由表达式json[“name”]和json[“address”]引用。
这些索引运算符可以层叠。例如,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"].
为了引用数组或对象中的所有值,可以使用通配符索引*。例如,if the outermost JSON element is an array,then the expression json[*] refers to every element in the array.
JSON Property Expressions
属性表达式是如上所述的结构表达式,然后是A。(点)运算符和属性名。目前,唯一支持的属性是类型和大小。The type property returns the type of the JSON value referred to by the JSON structure expression.例如,if the outermost JSON element is an array,数组的第一个元素是一个字符串,then the expression json[0].type would have a value of string.The size property,只能应用于数组,returns the number of elements in the array.
字符串文字表达式
字符串文字表达式只是一个带引号的字符串值,例如“这是字符串文本表达式”。
FME Licensing Level
FME Professional edition and above
编辑变压器参数
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,在一些变压器中也有。To access a menu of these options,clickbeside the applicable parameter.For more information,看见Transformer Parameter Menu Options.
变压器类别
Search FME Knowledge Center
Search for samples and information about this transformer on theFME知识中心.
TagsKeywords: JSONExploder