How can I extract and display only the value from a product's metafield?

How can I extract and display only the value from a product's metafield?

pavel_shopio24
Shopify Partner
5 0 0

I have the task, i need to extract the value from metafield of the product:

When I display the whole metafield> 

{{ product.metafields.product.passform}}

 

it shows me the following> {"type":"root","children":[{"type":"paragraph","children":[{"type":"text","value":"Test"}]}]}

 

how can I display only the value, which is "Test" in this case?

Replies 2 (2)

pavel_shopio24
Shopify Partner
5 0 0

I found the solution: 

{% assign jsonData = product.metafields.product.passform | split: 'value":"' %}
{% assign valuePart = jsonData[1] | split: '"' %}
{{ valuePart[0] }}

pavel_shopio24
Shopify Partner
5 0 0

{{ product.metafields.product.passform | metafield_tag }}

This is the solution