Loop Over JSON Help - Resolved

Hi, I’m struggling with something and it works in one place, not another.

Given this JSON:

{  
   "data":[  
  {  
	  	"type":"image",
     "item":{  
        "link":"linkitem",
        "url":"www.x.com",
        "summary":"descriptiontext"
     }
  },
  {  
	     "type":"image",
     "item":{  
        "link":"linkitem2",
        "url":"www.y.com",
        "summary":"description text 2"
     }
  }
   ]
}

And the code of:

{{ $dataJ := getJSON (printf "http://matmatthews.000webhostapp.com/parseXml.php") }}
	{{ range first 8 (where $dataJ.data ".type" "eq" "image") }}
	    <li>{{ .image.summary }}<li>
	{{ end }}

Why does it not work? I’ve matched another JSON file and used the same code. I just don’t get it. Any pointers would be good.

I ran your code snippet and got this output. Is that not expected?

<li>Southside Spinners, Antranig, Riva Starr, Turno, Harry Romero, Dateless, Mihalis Safras, Michael Bibi, Martin Ikin, David Penn, Endor<li>
<li>House Mat by Mat Matthews featuring Slam Dunk'd, Ozzie London, Mat Hold, Ali Brown, Deep Dimension, 2pole<li>

Well, that’s annoying :slight_smile: Suspect it’s cached something or the browser is being daft :slight_smile:

Possibly so :slightly_smiling_face:

As a side note, you may want to pipe to safeHTML

<li>{{ .image.summary | safeHTML }}<li>