Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Below you can find an example to convert a given JSON to CSV using the FreeMarker Transformer command:

Code Block
languageyaml
# The JSON to be converted (can be any structure)
body: {
        "columnsCount": 3,
        "rowsCount": 2,
        "headers": ["firstName", "lastName", "age"],
        "rows": [
            {
                "firstName": "Max",
                "lastName": "Smith",
                "age": "38"
            },
            {
                "firstName": "Susann",
                "lastName": "Mayr Wan",
                "age": "44"
            }
        ]
    }

pipeline:
    - transform.ftl:
        # The conversion rule from JSON -> CSV
        template: |
            "${body.headers[0]}", "${body.headers[1]}", "${body.headers[2]}"
            <#list body.rows as person>
            "${person.firstName}",  "${person.lastName}", "${person.age}"
            </#list>

...