Metafields type vs value_type breaks the liquid json function
Open
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 11.9k
- Forks
- 1.5k
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 3
Description
I followed the directions to migrate to "type" instead of "value_type" for Shopify metafields.
https://shopify.dev/apps/metafields/migration
After switching, I can no longer transform metafields to json in liquid.
This code has always worked:
{{ product.metafields.merch | json }}
Actual output:

Expected output:

Old API code (works):
{
key: 'preview_image',
value: JSON.stringify({
src: previewImage.url,
contentType: previewImage.contentType,
}),
value_type: "json_string",
namespace: "merch",
}
New API code (breaks liquid):
{
key: 'preview_image',
value: JSON.stringify({
src: previewImage.url,
contentType: previewImage.contentType,
}),
type: "json",
namespace: "merch",
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Liquid json filter with the issue's old value_type and new type metafield examples. Trace the json filter behavior for Shopify metafields, then add coverage for the new type form and confirm the output matches the expected JSON representation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, ruby
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100