How to use range first 3 over a json object?

"some_key": {
    "Article": {
        "id": "leg_0000",
        "value": "This is the title",
         }
   },
 "other_key": {
    "Article": {
        "id": "leg_0001",
        "value": "This is the another title",
         }
   }

I receive a json object similar to this format with many elements and on the landing page I’d like to show first 3 of them. How can I do that? Thanks in advance.

{{ $file := .Params.datafile}}
{{ $data := getJSON $file }}
{{ range first 3 $data.items }}
...

short cut & paste from my site

1 Like

Thanks a lot for the answer but now I get this error:
wrong type for value; expected string; got map[string]interface
To give some more information, I have an rss feed that I parse with python and create a json file out of it and store it in .Site.Data. Then I get the data inside my template with {{.Site.Data.rss}}. I don’t understand what is wrong? The same rss.json file used to have an array of articles and I could do it but now I can’t.

Because you range over an object. @ju52’s answer with your json above:

{{ $file := .Params.datafile}}
{{ $data := getJSON $file }}
{{ range first 3 $data }}
  {{.Article.value}}
{{/end}}
1 Like