Accessing data from JSON can’t evaluate field in type []interface {} (MAP)

Can anyone help? :melting_face:

[
    {
        "item_number": 1,
        "tipe_series":
        [
            "Google",
            "Pixel 7 Pro"
        ]
    },
    {
        "item_number": 2,
        "tipe_series":
        [
            "Google",
            "Pixel 6a"
        ]
    }
]

Error description

> can’t evaluate field tipe_series in type []interface {}

My Shortcodes

{{ range $index, $item := .Site.Data.mobile.google }} 

{{ range .tipe_series }}
{{.}}
{{ end}}

{{ end }}

Result

[Google Pixel 7 Pro Google Pixel 6a]

which should

- Google Pixel 7 Pro
- Google Pixel 6a

I am unable to reproduce the problem as described.

data/mobile/google.json

[
  {
    "item_number": 1,
    "tipe_series": [
      "Google",
      "Pixel 7 Pro"
    ]
  },
  {
    "item_number": 2,
    "tipe_series": [
      "Google",
      "Pixel 6a"
    ]
  }
]

template code

{{ range site.Data.mobile.google }}
  {{ range .tipe_series }}
    <p>{{ . }}</p>
  {{ end }}
{{ end }}

produces this HTML

<p>Google</p>
<p>Pixel 7 Pro</p>
<p>Google</p>
<p>Pixel 6a</p>
1 Like

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