JSONFlattener
Flattens JSON (JavaScript Object Notation) objects, extracting the object keys and values into FME feature attributes.
For example, consider a feature which has an attribute named json containing the following text:
{ "paramName":"GeocodeResult", "dataType":"GPFeatureRecordSetLayer", "value": { "geometryType":"esriGeometryPoint", "spatialReference": {"wkid":4326 } } }
After going through the JSONFlattener, the following attributes will have been added to the feature:
Attribute Name | Attribute Value |
---|---|
paramName | GeocodeResult |
dataType | GPFeatureRecordSetLayer |
value.geometryType | esriGeometryPoint |
value.spatialReference.wkid | 4326 |
Output Ports
Features which are successfully processed will be output through this port.
Features which could not be successfully processed will 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 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.
Flattening Parameters
If this parameter 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, as shown in the above example.
This parameter may be used to provide a string with which to prefix the newly-created attributes.
Exposes any attributes so they can be used by other transformers. Type directly in the text box or click the browse button to display the editor and add attributes there.
Error Handling Parameters
Name of the list attribute that contains information on JSON validation errors. The features that exit the transformer through the <Rejected> output port will have validation errors listed in this list attribute. Each validation error message is made up of four parts:
- Error description
- Line number where the error occurred
- Column number where the error occurred
- Error type/severity
Note: List attributes are not accessible from the output schema in Workbench unless they are first processed using a transformer that operates on them, such as ListExploder or ListConcatenator. All list attribute transformers are displayed in the Contents pane of the Transformer Help under Lists. Alternatively, AttributeExposer can be used.
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, click beside the applicable parameter. For more information, see Transformer Parameter Menu Options.
Transformer Categories
Search FME Knowledge Center
Search for samples and information about this transformer on the FME Knowledge Center.