Skip to main content
Question

DataVirtualizationJSONPaginate


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

The DataVirtualizationJSONPaginate custom transformer helps create JSON-formatted responses suitable for use with FME’s Data Virtualization functionality. It allows users to paginate FME features and generate HTTP-like responses containing metadata and content suitable for integration with FME Flow’s virtual API endpoints.

The transformer supports two pagination strategies: Page-based Pagination and Offset-based Pagination.

Input Ports

Input: Accepts a stream of features to be paginated and converted into a JSON response.

Output Ports

Output: Returns a single feature with HTTP response-like attributes and JSON content formatted for Data Virtualization.

Parameters

Attributes to Write

A list of attribute names to include in the data array of the JSON response.

Pagination Type

Specifies the pagination strategy:

- Page-based Pagination

- Offset-based Pagination

If Page-based Pagination is selected:

Current Page: The current page number (starting from 0 or 1 depending on the API convention).

Per Page: Number of items to include per page.

Last Page: Total number of pages available. (will be calculated if Internal Filtering is enabled)

Total: Total number of items in the dataset. (will be calculated if Internal Filtering is enabled)

FME Flow API Link: Base URL for generating pagination links (e.g., https://FMEFlowURL/api/apiname/endpoint?page=).

If Offset-based Pagination is selected:

Offset: The number of items to skip before starting the current page.

Limit: The number of items to include in the current response.

Total: Total number of items in the dataset. (will be calculated if Internal Filtering is enabled)

Enable Internal Filtering

Enables automatic filtering of the incoming features to include only those relevant to the current page or offset.

Output Attributes

The transformer outputs a single feature with the following attributes:

response.status_code: HTTP status code (typically 200).

response.body.content: The JSON string representing the data and pagination metadata.

response.body.content_type: The MIME type (application/json).

response.body.content_file_path (optional): Path to a file containing the response body, if needed.

JSON Output Format

Offset-based Example

{

"data": [

{ "id": 101, "name": "Item 101" },

{ "id": 102, "name": "Item 102" }

],

"meta": {

"offset": 100,

"limit": 2,

"total": 1000

}

}

Page-based Example

{

"data": [...],

"meta": {

"total": 100,

"per_page": 10,

"current_page": 1,

"last_page": 10

},

"links": {

"self": "https://FMEFlowURL/api/apiname/endpoint?page=1",

"next": "https://FMEFlowURL/api/apiname/endpoint?page=2",

"prev": "https://FMEFlowURL/api/apiname/endpoint?page=0"

}

}

Use Cases

Creating paginated JSON responses from datasets.

Building custom API endpoints using FME Flow Data Virtualization.

Simulating RESTful API behavior with dynamic data from FME.

Notes

The transformer does not fetch data from external sources; it only prepares FME features into paginated JSON.

If "Enable Internal Filtering" is not checked, the transformer will not limit the input features, but still compute and emit appropriate pagination metadata.



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