Hi everyone.
I have strange issue with rendering app metafields with type of json in app embed with liquid.
Here is the issue.
value: {{ app.metafields.shipready.app_settings.value }}
Type: {{ app.metafields.shipready.app_settings.type }}
It’s printing the following data
value: {"app_name":"Example App","app_version":"Beta"}
Type: json
When I want to access the object by key, it’s shows nothing.
{% assign app_data = app.metafields.shipready.app_settings.value %}
name: {{ app_data['app_name'] }}
I tried this as well but no luck.
name: {{ app_data[0] }}
I also tried this but not working
{{ app.metafields.shipready.app_settings.value['app_name'] }}
What am I doing wrong? Is it even possible to access json metafield with key?
Thank you!
1 Like
Hello! Here are the instructions for accessing metafields of type JSON. What you are doing is correct, however, I’d look into why printing the value of your metafield uses :
access instead of =>
access like my example…
This seems more like a Liquid issue, is it only reproducible within your theme app extension?
3 Likes
Hey @SelenaL-Shopify!
Thanks for the replay. Yes this issue is only in App embed. Shopify Product Metafields with json type seem to work fine.
Thank you!
1 Like
Interesting! Can you share the shop and theme you’re using so I can investigate further? If you’re not comfortable sharing publicly, you’re can go through Shopify support
Hi Selena!
Honestly, I tested this on multiple development stores with different apps and still same issue. I have some students reported this as well.
I can share the development store details but it’s happening on all stores for app metafields.
Here is the store url: shipready-dev.myshopify.com
Here is theme id: 126379622475
Thank you!
1 Like