Can't get key/value from hash

22 views
Skip to first unread message

John Weiss

unread,
Jun 16, 2024, 10:09:47 PM6/16/24
to dotliquid
Dotliquid version
Not sure. Going to use this on Azure Logic Apps. Errors are coming here:
https://pramodvalavala-msft.github.io/liquid-playground/

Expected
The doc states
"When iterating a hash, item[0] contains the key, and item[1] contains the value"
https://github.com/Shopify/liquid/wiki/Liquid-for-Designers

Getting
But i'm getting blanks.

Code
Template:
  {
  {%- for item in answers -%}
    {%- assign oSubAnswers = item.answer -%}
    {{oSubAnswers}}
    {%- for subAns in oSubAnswers -%}
      {{ subAns[0] }}: {{ subAns[1] }}
    {%- endfor -%}

  {%- endfor -%}
  }


Data:
{
    "answers": {
      "12": {
        "answer": {
          "field_1": "John",
          "field_3": "White",
          "field_5": 1111111,
          "field_4": "111-111-1111"
        }
      },
      "22": {
        "answer": {
          "field_2": "111 Ventura Blvd",
          "field_3": "111-111-1111",
          "field_8": "johna...@gmail.com",
          "field_7": "https://tort.xyz",
          "field_6": "10 am to 6 pm, M-F"
        }
     }
   }
}


Output:
  {
    [field_1, John][field_3, White][field_5, 1111111][field_4, 111-111-1111][itemName, answer]
      :
      :
      :
      :
      :

    [field_2, 111 Ventura Blvd][field_3, 111-111-1111][field_8, johna...@gmail.com][field_7, https://tort.xyz][field_6, 10 am to 6 pm, M-F][itemName, answer]
      :
      :
      :
      :
      :
      :

  }
Reply all
Reply to author
Forward
0 new messages