json-to-csv()

string json-to-csv(OXN array)

The json-to-csv function translates the given OXN array into CSV as described in RFC 4180arrow-up-right. The array entries must either be arrays or "flat" objects with number, boolean, string, or null values.

If any errors occur, an empty string is returned.

Example: array of arrays

<flow>

  <template out="$arr">
  [
    [ 1, "  foo ", true ],
    [ 2, "ba, r", false ],
    [ 3.21, "q\"u\"x", true ],
    [ '', null, '' ]
  ]
  </template>
  <eval out="$csv">json-to-csv($arr)</eval>
  <copy in="$csv"/>
</flow>

creates the following output:

1,  foo ,true
2,"ba, r",false
3.21,"q""u""x",true
,,

Example: array of "flat" objects

creates the same output.

Last updated