# Extracting Specific Value from a Nested Json Data File

**URL:** https://discourse.gohugo.io/t/extracting-specific-value-from-a-nested-json-data-file/21973
**Category:** support
**Created:** [November 25, 2019, 3:35pm UTC](https://discourse.gohugo.io/t/extracting-specific-value-from-a-nested-json-data-file/21973 "2019-11-25T15:35:35Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Shash](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/shash/32/10039_2.png) [@Shash](https://discourse.gohugo.io/u/Shash)
#### Post date: [November 25, 2019, 3:35pm UTC](https://discourse.gohugo.io/t/extracting-specific-value-from-a-nested-json-data-file/21973/1 "2019-11-25T15:35:35Z")

</div>

Hi All,  
I’m new to Hugo so please pardon me if this question was already answered. I did try looking around discourse quite a bit but wasn’t able to find an answer.

I created a data file called quotes.json and it’s contents are:  
{ “Robert” : {  
“quote” : “Quote1”,  
“name” : “Robert Heinlein”,  
“book” :“Time Enough for Love”  
},  
“Charles” : {  
“quote” : “Quote2”,  
“name” : “Charles Buckowski”,  
“book” : “Post Office”  
}  
}

Inside my layouts folder, I have an html file that does:  
{{ range .Site.Data.quotes }}  
{{ .quote}}  
{{end}}

However, this displays value of “quote” for both “Robert” and “Charles”. How can I define it such that it only shows the value of the author I choose - for instance “Robert”.

Do I need to define a value in the front matter? Any assistance is much appreciated.

Thanks,  
Shash

---

<div class="post-metadata">

### Author: ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)
#### Post date: [November 25, 2019, 4:15pm UTC](https://discourse.gohugo.io/t/extracting-specific-value-from-a-nested-json-data-file/21973/2 "2019-11-25T16:15:44Z")

</div>

Do you mean you’d like to only show the quotes of a single author?

Also, it isn’t clear from your example which front matter you are referring to. Please share a sample project showing your project structure. 🙂

---

<div class="post-metadata">

### Author: ![regis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/regis/32/4958_2.png) [@regis](https://discourse.gohugo.io/u/regis)
#### Post date: [November 25, 2019, 8:57pm UTC](https://discourse.gohugo.io/t/extracting-specific-value-from-a-nested-json-data-file/21973/3 "2019-11-25T20:57:26Z")

</div>

```auto
{{ $quotes := .Site.Data.quotes }}
{{ with index $quotes "charles" }}
  {{ .name }}
{{ end }}

```

I think this is case agnostic, so “Charles” or “charles” should both work, but not sure.

---

<div class="post-metadata">

### Author: ![Shash](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/shash/32/10039_2.png) [@Shash](https://discourse.gohugo.io/u/Shash)
#### Post date: [November 26, 2019, 4:53am UTC](https://discourse.gohugo.io/t/extracting-specific-value-from-a-nested-json-data-file/21973/4 "2019-11-26T04:53:02Z")

</div>

Worked like a charm! This just helped me learn about _index_ as well. Thanks a ton mate!
