Transform json data inside table / show limited and readable data

Hi Al,

I load data in my table through a restapi, inside my table I have a column that shows json data, I would like that column to only show the category names in a readable way.

[{"id":109,"name":"Kamperen & Outdoor","bol_id":15270,"bol_category_id":null,"results":12000,"pivot":{"product_data_id":642640,"bol_category_id":109}},{"id":1579,"name":"Hengelsport","bol_id":15592,"bol_category_id":109,"results":12000,"pivot":{"product_data_id":642640,"bol_category_id":1579}},{"id":1595,"name":"Roofvis","bol_id":50090,"bol_category_id":1579,"results":12000,"pivot":{"product_data_id":642640,"bol_category_id":1595}},{"id":5922,"name":"Kunstaas","bol_id":50212,"bol_category_id":1595,"results":7406,"pivot":{"product_data_id":642640,"bol_category_id":5922}},{"id":11191,"name":"Meerval","bol_id":64907,"bol_category_id":1579,"results":5651,"pivot":{"product_data_id":642640,"bol_category_id":11191}},{"id":11232,"name":"Kunstaas","bol_id":64908,"bol_category_id":11191,"results":5432,"pivot":{"product_data_id":642640,"bol_category_id":11232}}]

What I want to see in my column or new column is only the content of the field name like below example

Kamperen & Outdoor, Hengelsport, Roofvis, Kunstaas, Meerval

Can somebody give some hints on how to do so?

Like this?

Thanks for the quick reply :slight_smile: Because the data is based on a row I would need it to be populated in one cell like this

"Kamperen & Outdoor, Hengelsport, Roofvis, Kunstaas, Meerval"

Not sure what the name of your array is but here is what you could do...
For example only, I created a transformer:


Then using a js query, iterate over the array returned by the transformer...

var category = [];

for (i=0;i<transformer12.value.length;i++){
  category.push(transformer12.value[i].name)
}

return category

You can then use a custom column in the table to contain all of the names...returned from the js query

thanks for that, it works but then it still return a array format (sorry if that is wrong or stupid, still learning)

["Kamperen & Outdoor","Hengelsport","Roofvis","Kunstaas","Meerval","Kunstaas"]

Can I transform this to normal text?

It's an array, so you can just join it, but this makes sorting, filtering etc later very impractical.

var category = [];

for (i=0;i<transformer12.value.length;i++){
  category.push(transformer12.value[i].name)
}

return category.join(", ")
2 Likes

Great stuff! thanks a lot for helping me