Nested Data in JSON String

Hi there,

So I have this app, which pulls data into Google sheets. However, most of the results, there is a nested set of data in the column. (See venue). Is it possible for me to split that out similarly so that each of those gets separated into their own column once it's pulled into Google Sheets?

Hi @DSomers16, Yes, you can use multiple approaches to resolve this.

  1. Create a custom column. Use the selected row property to populate it with desired data.
  2. Use a JS transformer to flatten this data per your requirements.

Try something like the following as a transformer in your query. You'd want to change lines like "newData.user_id =" to something like "newData.venue_name =" based on the example you gave.

const flattenData = (x) => {
    let newData = {}
    // Examples of top-level stuff in JSON = =

    // Examples of nested stuff in JSON
    newData.user_id =
    newData.user_name =
    // Example of splitting a string while I'm already here
    var fullName =' ')
    newData.first_name = fullName[0]
    newData.last_name = fullName[fullName.length - 1]
    return newData
  const results = => flattenData(a))
  const newData = ({}, {search: {total:, results: results}})

  return newData
1 Like

Thank you. This did the trick!


Thanks for the solution! :sunglasses: