How can I convert a metafield string to a Liquid object?

Hi there,
I am retreiving a metafield like so:

{% assign foo = order.metafields.bar.service %}

If I output the metafield like this:

{{foo}}

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!

See below issue, may it useful.

https://github.com/Shopify/liquid/issues/432

Hi @Donfetto ,

You can try with code:

{% assign foo = order.metafields.bar.service %}
{{ foo['service_code'] }}

Hope it helps!