New 'json_string' value type for Metafield object

Ryan
Shopify Staff
492 42 113

The Metafield object has been updated with a new 'json_string' value type. This makes it easy to store arbitrary structured data within the Shopify platform and access it inside Liquid templates. Notably, when accessing the value of 'json_string' value type metafields, the data is deserialized to an iterable hash or array.

 

See more examples: https://help.shopify.com/en/themes/liquid/objects/metafield

 

Happy Coding!

Ryan | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Replies 10 (10)
RustyDev
Shopify Partner
12 0 4

This is great news!

Unfortunately, it doesn't seem to work with the bulk editor:

/admin/bulk?resource_name=Page&edit=metafields.json_test.json_key:json_string

This saves and a string instead of a json_string:

{
"id": 4090352107572,
"namespace": "json_test",
"key": "json_key",
"value": "[\"one\",\"two\",\"three\"]",
"value_type": "string",
"description": null,
"owner_id": 7266369588,
"created_at": "2018-10-27T08:27:08-07:00",
"updated_at": "2018-10-27T08:27:08-07:00",
"owner_resource": "page"
}