JSONExtractor
Extracts portions of JSON (JavaScript Object Notation) formatted text into feature attributes.
Parameters
Source
Allows for selecting between one of two options for JSON input: JSON Document or File/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.
Extract Queries
This parameter identifies the feature attribute into which the result of the JSON query should be put.
This parameter is the JSON query whose value will be stored in the target attribute.
Each cell in the JSON Query column contains a button that opens a dialog containing the structure of the JSON dataset in a tree form. If the JSONExtractor is set to read from a file or URL, then 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 primarily used to refer to values in some JSON text. They can also be used to extract some metadata about the JSON text, such as the type (object, array, string, etc.) of JSON value or the number of elements in an array. The outermost JSON value, which must be an object or an array, is always referred to by the term "json". Contained values can be referred to using JavaScript-like square bracket index operators.
A value in an array can be referred to using its zero-based position in the array (for example, json[2] for the third element).
A value in an object can be referred to using its object key name
json["key"]
All of the values in an array or object can be collectively referred to using a wildcard index
json[*]
The query used by this transformer can have multiple expressions, which are separated by a '+' operator, as well as string literal values. This allows more complex attribute values to be easily created from the JSON text. For example:
json["name"]["first"] + " " + json["name"]["last"]
The JSONFragmenter transformer contains more information on JSON queries.
If the JSON query cannot be fully evaluated, a message will be logged, and the feature will be output without setting the target attribute.
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, click beside the applicable parameter. For more information, see Transformer Parameter Menu Options.
Transformer Categories
FME Licensing Level
FME Professional edition and above
Search FME Community
Search for samples and information about this transformer on the FME Community.