Skip to content

Instantly share code, notes, and snippets.

@scottythered
Last active March 1, 2018 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottythered/22f421a568d72ff6bd12883471619dcd to your computer and use it in GitHub Desktop.
Save scottythered/22f421a568d72ff6bd12883471619dcd to your computer and use it in GitHub Desktop.

Sample data -- the multi-value connector is the plus sign (+):

col1 col2 col3
one blah scott
two blah scott+jessica
three blah jessica+scott

Under templating, use this if-statement in your row template:

   {
      "col1" : {{jsonize(cells["col1"].value)}},
      "col2" : {{jsonize(cells["col2"].value)}},
      "col3" : {{if((cells["col3"].value.contains("+")),(jsonize(cells["col3"].value.split("+"))),(jsonize(cells["col3"].value)))}}
    } 

The result is valid JSON:

{
  "rows" : [
    {
      "col1" : "one",
      "col2" : "blah",
      "col3" : "scott"
    },
    {
      "col1" : "two",
      "col2" : "blah",
      "col3" : ["scott","jessica"]
    },
    {
      "col1" : "three",
      "col2" : "blah",
      "col3" : ["jessica","scott"]
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment