Hello all
I have two text columns (which are populated from a multi choice component.
Tag - could be “Tag 1, Tag 2, Tag 3” (or could be empty)
Location - could be "Location 1, Location 2) - or again empty.
I need to get that into JSON like below
{
“filters”: {
“tags”: [“Tag 1”, “Tag 2”],
“location”: [“Location 1”, “Location 2”]
}
}
I know that’s possible, and am sure I have done it before - but what’s the best way?
Is JavaScript column a good bet, or can I use JSON Object / Template?
Thanks,
Andrew
I would use Split Text columns to create an array for tags and location, and then use a JSON Object columns to build the JSON.
3 Likes
Jeff beat me to it, but yes - split text then JSON. Only difference is I would suggest a JSON Template column, like so:
{
"filters": {
"tags": [$tags],
"location": [$locations]
}
}
Resultant JSON:
{
"filters": {
"tags": [
"Tag 1",
"Tag 2",
"Tag 3"
],
"location": [
"Location 1",
"Location 2"
]
}
}
3 Likes
Got it thanks - only slight difference for me is that that finished JSON then gets fed into another final JSON Object column - so in my template I did
{“tags”:[$tags],“location”:[$location]}
(ie - left the filter key off, as that is then added in by my “final” JSON object column)
Thanks both! Knew you would know!
Andrew
2 Likes
system
Closed
5
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.