Presenting JSON data properly

I have a JSON file, where i’m presenting the data from.
It’s working fine, but i have some formating issues.

The json file looks like this :

{
“Name” : “Fran”,
“Time” : “For Time”,
“Description” : [
“21 - 15 - 9 Reps for time”,
“thrusters 95/65 LB”,
“Pull-Ups”
],
“Equipment” : [
“Pull-Up Bar”,
“Barbell”
],
“Skill_Level” : “Medium”,
“Type” : “Girl”,
“Other” : “”
}

And i’m presenting it using this code :

    {{ range $data.wod }}
    <div class="w-full rounded overflow-hidden shadow-lg">          
      <div class="px-6 py-4">
        <div class="font-bold text-xl mb-2">{{ .Name }}</div>
        <p class="text-gray-700 text-base">
          {{ .text }}
        </p>
        <p>
          Type : {{ .Time }}
        </p>
        <p>
          Description : {{ .Description }}
        </p>
        <p>
          Equipment : {{ .Equipment }}
        </p>
        <p>
          Skill Level : {{ .Skill_Level}}
        </p>
        <p>
          Type : {{ .Type }}
        </p>
        <p>
          Other : {{ .Other }}
        </p>
      </div>
    </div>
    {{end}}

My problem is, that i would like to present the data, in “Description” as multiple lines.
Today it’s being shown as a single line.

I’m guessing that i need to run thru it as a loop again ?

I can’t get my head around how to fix this.

Thanks

Something like this, may be?

<p>Description: <ul>
{{ range .Description }}
<li>.</li>
{{ end }}
</ul></p>
1 Like

Thanks. It’s a lot closer, but there is no data, only .

Any idea ?

{{.}}

instead of . should fix that, shouldn’t it?

2 Likes

You are fantastic. Thank you so much.

That worked :slight_smile:

If you know how many hours i have spend trying to get this to work :slight_smile:

Thanks :slight_smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.