How to Fetch All Values Inside a Nested Hash Using Liquid Parsing?

How to Fetch All Values Inside a Nested Hash Using Liquid Parsing?

dsr24
Visitor
1 0 0
I'm currently working on a project where I need to parse a nested JSON hash using Liquid. However, I'm encountering difficulties in extracting all the inner values from the hash. Here's an example of the nested hash I'm dealing with: 
 
{% assign dco_data = '{
  "DCO111": {
    "DCOIDlogo": "423",
    "PARTNER": "One",
    "promo_code": "pro",
    "offer": "Valentine"
  },
  "DCO222": {
    "DCOIDlogo": "342",
    "PARTNER": "Two",
    "promo_code": "promotwo",
    "offer": "Christmas"
  }
}' | parse_json %}

{% assign dco_id = 'DCO111' %}
{% assign dco_info = dco_data[dco_id] %}

DCOIDlogo: {{ dco_info.DCOIDlogo }}
PARTNER: {{ dco_info.PARTNER }}
promo_code: {{ dco_info.promo_code }}
offer: {{ dco_info.offer }}

I'm attempting to extract all the inner values from this nested hash and output them. However, despite my efforts, I'm not getting the desired result. Currently, I'm using the following code: {% assign dco_id = 'DCO111' %} {% assign dco_info = dco_data[dco_id] %} DCOIDlogo: {{ dco_info.DCOIDlogo }}  Can someone guide how to effectively achieve this task using Liquid? I'm open to any help or suggestions. Thank you!

 
Replies 0 (0)