How to use liquid templates in the theme for metafields whose type is json, using liquid syntax for

I created a metafields his type is ‘json’ and the content is

[
{
“id”: 664798,
“uid”: 3,
“purchase_date”: “2025-04-18T09:05:36+00:00”,
“seller_account”: “xxxxxx”,
“amazon_order_id”: “xxx-xxxxxxxx-xxxxxxxx”,
“order_total”: “108.79 GBP”,
“a_sin”: “xxxxxx”,
“buyer_name”: “”,
“seller_id”: “”,
“buyer_email”: “no email”,
“shipping_address”: “xxxxxx”,
“create_time”: “2025-04-19 16:24:56”,
“update_time”: “2025-04-19 16:24:56”,
“product_name”: “xxxxxxxx”,
“product_img”: null,
“is_done_order_info”: 1,
“is_done_product_info”: 0,
“remark”: “{"SellerSKU":"xxx","OrderItemId":"xxx-xxxxxxxx-xxxxxxxx"}”,
“auth_id”: 1,
“platform”: “amazon”,
“state”: “保修中”,
“end_date”: “2026-10-18”,
“days_remaining”: 539
}
]

I tried to loop through the theme using the following code

{% assign warranty_list1 = customer.metafields.custom.shopify_warranty | json %}
{% assign warranty_list2 = customer.metafields.custom.shopify_warranty | parse_json %}
| json will report an error, | parse_json has no effect and doesn’t convert to an array because I can’t get the value of warranty_list.size properly,How should I convert properly
ps:

{% assign warranty_list = customer.metafields.custom.shopify_warranty %} It won’t work if you use it directly.

Hello @Joey_frizzlife
I’d be happy to help with this! To give you the most accurate feedback, could you kindly share your store URL? This will allow me to provide tailored suggestions for improvement.

https://shopify.dev/docs/api/liquid/objects/metafield#metafield-accessing-metafields-of-type-json

you need to use .value:

{% assign warranty_list = customer.metafields.custom.shopify_warranty.value %}
{{ warranty_list.seller_account }}

json converts object to its textual representation, like stringify,

parse_json does not exist.

2 Likes