Skip to main content
Contributor I
March 25, 2022
Solved

Template tag outputs JSON, how to format as HTML??

  • March 25, 2022
  • 3 replies
  • 303 views

Hello,

Our template tag {{ item.ItemOptions }} is showing as:

{'Color': 'Assorted', 'Color_Choices': 'Green, Red, Blue, Yellow, Pink', 'Text_Field': 'Text Field', 'Text_Area': 'Text Area', 'File_Upload': 'Features Needed.txt ', 'Select_Dropdown': 'Select Dropdown 1', 'Select_Radio': 'Select Radio 1', 'Select_Checkbox': 'Select Checkbox 1, Select Checkbox 2, Select Checkbox 3', 'Multiple_Select': 'Multiple Select 1, Multiple Select 2, Multiple Select 3'}

How can I format the output as HTML like:

Color: Assorted
Color_choices: Green, Red, Blue, Yellow, Pink
Text_Field: Text Field
etc.....

Thanks for any help!

 

    This topic has been closed for replies.
    Best answer by stevekem

    Finally figured it out. In case anyone else might find this useful, I used:

    {% for k, v in item.ItemOptions.items %}
      {{ k }}: {{ v }}
    {% endfor %}

    3 replies

    stevekemAuthor
    Contributor I
    March 26, 2022

    So apparently it is outputting an OBJECT not JSON, my apologies I’m new 😁

     

    I tried:

    {% for obj in item.ItemOptions %}
        <p>{{ obj }}</p>
    {% endfor %}

     

    But it’s only showing:

    Color
    Color_choices
    Text_Field

     

    And not:

    Color: Assorted
    Color_choices: Green, Red, Blue, Yellow, Pink
    Text_Field: Text Field

    stevekemAuthorAnswer
    Contributor I
    March 26, 2022

    Finally figured it out. In case anyone else might find this useful, I used:

    {% for k, v in item.ItemOptions.items %}
      {{ k }}: {{ v }}
    {% endfor %}

    Taylor Tarpley
    Community Manager
    Community Manager
    April 1, 2022

    Hi @stevekem

     

    Thank you so much for sharing your your solution with the Community! I know it will definitely help someone else in the future who is also experiencing this issue!

     

    Thanks for participating in our Community and helping others!

    -Taylor