Working on a multi dimensional json string

Working on a multi dimensional json string

Patrciv
Shopify Partner
5 0 1

Hello,

 

I am creating an app where I would be storing the data in the shopify products backend as a meta field. The data is a json string which I would then use to create the frontend for the product page.

 

Here's the json string that I am storing in the metafields. I have created this in my app using JSON.stringify();

 

 

[{"min":"2","max":"4","discount":"2"},{"min":"5","max":"8","discount":"4"},{"min":"9","max":"+","discount":"6"}]

 

 

Now I am trying to loop through the array and create table to show the values, however I am having issues in converting the string to an array. Like js/php, I am trying to first loop through the each array and then loop again to get the values, however when converting the string to an array using split, its parsing each item into an array making it one array of 9 elements instead of 3.

 

I read about this on the internet and I read that creating multi dimensional arrays in liquid is not possible?

 

Is there any workaround that I can use to make this work.

 

Thanks.

Replies 0 (0)