Versions Compared

Key

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

...

Code Block
languageyaml
pipeline:
  - transform.ftl:
        # The input JSON
        model: {
                  "columnsCount": 3,
                  "rowsCount": 2,
                  "headers": ["firstName","lastName","age"],
                  "rows": [
                    {
                      "firstName": "Max",
                      "lastName": "Smith",
                      "age": "38"
                    },
                    {
                      "firstName": "Susann",
                      "lastName": "Mayr Wan",
                      "age": "44"
                    }
                  ]
              }
    
        # The conversion rule from JSON -> CSV
        template: |
            "${headers[0]}", "${headers[1]}", "${headers[2]}"
            <#list rows as person>

               "${person.firstName}", "${person.lastName}", "${person.age}"
            </#list>

This example will finally output a CSV like this:

Code Block
"firstName", "lastName", "age"
"Max", "Smith", "38"
"Susann", "Mayr Wan", "44"