Skip to main content
Question

DataVirtualizationJSONList


fmelizard
Safer
Forum|alt.badge.img+19
FME Hub user abizien just uploaded a new transformer to the FME Hub.

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

mail

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!
<strong>This post is closed to further activity.</strong><br /> It may be a question with a best answer, an implemented idea, or just a post needing no comment.<br /> If you have a follow-up or related question, please <a href="https://community.safe.com/topic/new">post a new question or idea</a>.<br /> If there is a genuine update to be made, please contact us and request that the post is reopened.

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings