JSONFragmenter公司
将JSON(JavaScript对象表示法)格式文本的部分提取到新的FME特性中。
输出端口
对于每个新创建的特征,由Output Attribute参数将包含JSON查询引用的JSON文本。
json_type属性将包含文本的json类型(object、array、string等),json_index参数将包含json值的object键或数组索引。
如果JSON查询无法完全计算,则会记录一条消息,并继续转换。
参数
The source JSON document. The JSON document can come from any string expression, including attribute values and workspace parameters.
The JSON Query parameter is the JSON query referring to the JSON values which will become new FME features.
JSON查询是一种引用JSON文本中的值的机制。最外层的JSON值必须是一个对象或一个数组,它总是被术语“JSON”引用。可以使用类似JavaScript的方括号索引操作符来引用包含的值。数组中的值可以使用其在数组中以零为基的位置来引用(例如,第三个元素的json[2])。
A value in an object can be referred to using its object key name. For example:
json[“键”]
All of the values in an array or object can be referred to collectively using a wildcard index. For example:
json[*]
此转换器使用的查询可以有多个表达式,用“+”运算符分隔。这允许转换器引用JSON文本不同区域中的值。例如:
json[“结果集\u 1”][*]+json[“结果集\u 2”][*]
See below for more information on JSON queries.
包含JSON片段的属性的名称。
展平参数
如果JSON查询生成了一个JSON对象,那么可以通过将设置为是的. 如果JSON查询生成一个JSON数组,并向Prefix New Attributes With参数,将创建一个列表属性,使用前缀作为列表名称,JSON数组值作为列表元素。
Note:列出属性无法从Workbench中的输出模式访问,除非首先使用对其进行操作的转换器(如ListExploderor列表串联器. 所有列表属性变换器都显示在“变换器帮助”的“内容”窗格中列表. 或者,AttributeExposer可以使用。
When the ‘Load Keys as Attributes’ parameter is set to ‘Yes’, this parameter controls the attributes which are created. 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, strings, etc) will become attribute values, while nested objects and arrays will be recursively flattened.
如果加载密钥作为属性的参数设置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, the format-specific keys will not be added as attributes, but will instead be handled by the appropriate format parser.
公开任何属性,以便其他转换器可以使用它们。直接在文本框中键入或单击“浏览”按钮以显示编辑器并在其中添加属性。
JSON查询
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
JSON结构表达式可以引用JSON文档中的值。最外层的JSON元素(必须是数组或对象)总是由术语JSON引用,并且该术语必须出现在每个JSON结构表达式的开头。子元素可以使用类似JavaScript的方括号索引操作符来引用。例如,如果最外层的元素是数组,那么数组的第一个元素可以由表达式json[0]引用,第二个元素可以由表达式json[1]引用,依此类推。同样,如果最外层的JSON元素是一个对象,带有键“name”和“address”,那么这些键的值可以分别由表达式JSON[“name”]和JSON[“address”]引用。
这些索引运算符可以级联。例如,如果最外层的JSON元素是一个具有键和“address”的对象,其值是一个包含键“city”和“province”的对象,那么这些值可以通过表达式JSON[“address”][“city”]和JSON[“address”][“province”]来引用。
为了引用数组或对象中的所有值,可以使用通配符索引*。例如,如果最外层的JSON元素是数组,那么表达式JSON[*]引用数组中的每个元素。
JSON属性表达式
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.
字符串文字表达式
字符串文字表达式只是一个带引号的字符串值,例如“this is A string literal expression”。
FME许可级别
FME专业版及以上
编辑变压器参数
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, see变压器参数菜单选项.
Transformer Categories
Search FME Knowledge Center
Search for samples and information about this transformer on theFME知识中心.
标签关键词:JSONExploder