Create JSON from Data Table

Thomas_937381 Posts: 196
edited December 2019 in Questions

Has anyone used Tables: Convert data table to text to convert a data table to JSON? If yes, can you please share your configuration?

Also upvoted this product request here:

Best Answer

  • Thomas_937381
    Thomas_937381 Posts: 196
    Answer ✓

    I got this to work with three steps in the following sequence. The table I was testing had three columns: Column A, Column B, Column C

    1. Tables: Convert data table to text
    Creates JSON array, sets value for concatenated string of text for each row.

    Row template:
    { "column-a": "columns['Column A']", "column-b": "columns['Column B']", "column-c": "columns['Column C']" },
    Row delimiter:

    2. Field: Set value of a text field
    This is need to place opening and closing brackets around the array. (Line breaks (\n) are not rendering in the text below.)

    Text to combine:
    [ {{name-of-field-from-above-step}} ]

    3. Text: Find and replace
    There is an extra comma (,) on the last row from the first step. We need to remove this. (Line breaks (\n) are not rendering in the text below.)

    Search term:
    }, ]
    } ]

    I subsequently tested this sequence with Field: Create fields from JSON and it works properly. Additional railguards may be required in these steps depending on the text/data passing through the sequence.