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

Solved

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

Joey_frizzlife
Visitor
2 0 0

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.
Accepted Solution (1)

tim
Shopify Partner
4539 546 1658

This is an accepted solution.

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.

If my post is helpful, hit the thumb up button -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com

View solution in original post

Replies 2 (2)

Stacksavy
New Member
9 0 0

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.

Here to help with questions, concerns & collector insights.

tim
Shopify Partner
4539 546 1658

This is an accepted solution.

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.

If my post is helpful, hit the thumb up button -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com