output the data from the metafield for the variant

Hi all.
Can you tell me what I’m doing wrong?
I have created product color options and display them on the page.
I also created a metafield where I insert the json code.
I add a different json code to each product.
Then I output it all to the product page.
But now for each variant I have only that information added ONLY for the first variant.
To avoid loading extra code, here’s this basic code
The code works correctly and outputs the necessary options, but the metafield data is the same for all

{% for variant in product.variants %} 
    
    
{{ product.variants[0].metafields.my_fields.json_variant }}

{% endfor %}

Sadly, it’s not possible to render the data dynamically with Liquid. You may want to add some JavaScript on top of that Liquid code and it should do the thing. Here is the link to a similar thread.

Thanks for the reply!

This doesn’t work for me, if I understand correctly

I have a generic json file that I go through and I can output my data for the individual variant (for the first variant 1 array of json, etc)

http://joxi.ru/Grq6VnEtR1JQOm

But this is not a flexible solution as the information is output in strict order.

I want to add the ability to load data for each individual variant

http://joxi.ru/Vrwap7LtjBJOP2
So that if I remove some of the options I don’t have to change the main json file

If I understand correctly the solution you suggested works like mine in the first case. You manually set the variant id in json and output when it matches.