The DataVirtualizationJSONList is a custom FME transformer that assists users in constructing HTTP JSON responses tailored for FME's Data Virtualization feature. It transforms incoming FME features into a structured JSON array, embedding selected attributes, and sets the necessary HTTP response attributes.
Parameters
List Name
Type: Text
Description: Specifies the key name under which the array of JSON objects will be nested in the response body.
Attributes to Write
Type: Attribute Selector
Description: Selects the attributes from incoming features to include in each JSON object within the array.
Output Attributes
The transformer sets the following attributes on the output features:
response.status_code: Set to 200, indicating a successful HTTP response.
response.body.content: Contains the JSON-formatted string representing the array of feature attributes.
response.body.content_type: Set to application/json, specifying the MIME type of the response.
response.body.content_file_path: Optional; if set, points to a file containing the JSON response body.
Example
Given three input features with the following attributes:
name
id
Alice
alice@example.com
01JTX10Z50Q0ZE4RGF6F0ED0S9
Bob
bob@example.com
01JTX116TQ6BK25ABVBYFS9KDR
Carol
carol@example.com
01JTX117TQ6BK25ABVBYFS9KDS
And the transformer parameters set as:
List Name: data
Attributes to Write: mail, name
The resulting response.body.content would be:
{
"data": [
{
"mail": "alice@example.com",
"name": "Alice"
},
{
"mail": "bob@example.com",
"name": "Bob"
},
{
"mail": "carol@example.com",
"name": "Carol"
}
]
}
This JSON structure can be utilized in HTTP responses within FME's Data Virtualization workflows.
Notes
Ensure that the selected attributes in Attributes to Write exist on all incoming features to avoid null values in the JSON output.
The transformer does not modify the geometry of features; it solely focuses on attribute transformation for HTTP response purposes.
Would you like to know more? Click here to find out more details!