metafield string to object

Shopify Partner
8 0 6

Hi there,
I am retreiving a metafield like so:

{% assign foo = %}

If I output the metafield like this: <p>{{foo}}</p
the following is displayed:
{"service_code":"A2P","pickup_id":"90325863","address_1":"32 some street","zip":"234","city":"Berlin","country_code":"DE"}
My question is: How can I access the keys directly. Like {{foo.service_code}} ?
Is there a way to turn this string into some kind of Liquid Object? What is the best way to do it?
I could do this via Javascript but as I also have to display the metafield information in Email notifications, so I am looking for a pure Liquid version to do this.
Thank you for your help!


Replies 2 (2)

Shopify Partner
400 61 79

See below issue, may it useful.

Shopify Plus Expert, Quality Service Provider, CONTACT ME for any kind of solutions.
Please like and accept solution. SKYPE -> live:gp21111990

Shopify Partner
4860 1001 1125

Hi @Donfetto ,

You can try with code:

{% assign foo = %}
{{ foo['service_code'] }}

Hope it helps!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify