Error on ranging over remote JSON with array

Working on ranging over a remote data file in a shortcode. Here’s the shortcode.

{{ $reviews := getJSON "" (dict "X-API-KEY" "APIKEY") }}
 <div class="reviews-slider disable-scrollbars">
 {{ $reviewsData := $ }}
 {{ range $reviewsData.reviews_data}}

   <div  id="_review8" itemprop="review" itemscope itemtype="" class="review">

     <p class="rev-text "> <span itemprop="reviewBody"> {{ .review_text }} </span> </p>
     <div class="rating">
        <img src="/images/star.svg" alt="star rating">
        <img src="/images/star.svg" alt="star rating">
        <img src="/images/star.svg" alt="star rating">
        <img src="/images/star.svg" alt="star rating">
        <img src="/images/star.svg" alt="star rating">

     <span itemprop="author" itemscope itemtype=""><span itemprop="name"><h5 class="rev-name"> {{ .author_title }} </h5></span></span>

     <p class="rev-date"> {{ .review_timestamp }} </p>
     <p hidden> {{ .review_rating }}</p>



Here's the JSON that is returned from the API.

“id”: “f198f77d-dbed-439b-bddc-e5b7f7eeaa01”,
“status”: “Success”,
“data”: [
“query”: “ChIJU7-Ou0Mp1IcReeTe5L195C4”,
“name”: “Foothills Overhead Doors LLC”,
“full_address”: “135 Leggett St, Jonesboro, AR 72401, United States”,
“borough”: null,
“street”: “135 Leggett St”,
“postal_code”: “72401”,
“area_service”: false,
“country_code”: “US”,
“country”: “United States of America”,
“city”: “Jonesboro”,
“us_state”: “Arkansas”,
“state”: “Arkansas”,
“plus_code”: “867FR8V5+JQ”,
“latitude”: 35.8441166,
“longitude”: -90.690511,
“time_zone”: “America/Chicago”,
“popular_times”: null,
“site”: “”,
“phone”: “+1 870-275-9899”,
“type”: “Garage door supplier”,
“logo”: “”,
“description”: “garage door and overhead door sales and service”,
“located_in”: “Citadel Mini Storage”,
“located_google_id”: “0x87d42943c315daa1:0xc4b81ceb52fc7a59”,
“category”: “Garage door supplier”,
“subtypes”: “Garage door supplier, Home improvement store”,
“posts”: null,
“reviews_tags”: [
“rating”: 5,
“reviews”: 34,
“reviews_data”: [
“author_link”: “Google Maps”,
“author_title”: “Scott Levins”,
“author_id”: “100324155557654257023”,
“author_image”: “”,
“review_text”: “Called Foothills with my problem, which was a bit more involved than I initially thought. Was told however it could still be fixed. Tony came out, and in no time had it fixed, and fixed what caused the problem. And he did it for less than the initial estimate. Professional, quick, and great price. I highly recommend!”,
“review_img_url”: “”,
“owner_answer”: “Happy to be of service!”,
“owner_answer_timestamp”: 1665843455,
“owner_answer_timestamp_datetime_utc”: “10/15/2022 14:17:35”,
“review_link”: “Google Maps”,
“review_rating”: 5,
“review_timestamp”: 1657221109,
“review_datetime_utc”: “07/07/2022 19:11:49”,
“review_likes”: 0
“review_id”: “ChdDSUhNMG9nS0VJQ0FnSUMyMS1lSnZBRRAB”,
“author_link”: “Google Maps”,
“author_title”: “Amber Stokes”,
“author_id”: “116704952676373942948”,
“author_image”: “”,
“review_text”: “These folks are GREAT! They took the time to repair my garage door TWICE and then told me honestly, that I needed to replace it as the fix simply wasn’t going to hold. The price on the new garage door was WAY lower than I expected! Fast service, friendly technicians, and great prices!”,
“review_img_url”: “”,
“owner_answer”: “Thank you! for being one of our valued customers. You have been a wonderful customer!”,
“owner_answer_timestamp”: 1653007431,
“owner_answer_timestamp_datetime_utc”: “05/20/2022 00:43:51”,
“review_link”: “Google Maps”,
“review_rating”: 5,
“review_timestamp”: 1651333106,
“review_datetime_utc”: “04/30/2022 15:38:26”,
“review_likes”: 1
“review_id”: “ChdDSUhNMG9nS0VJQ0FnSUMteVB2OXZnRRAB”,
“author_link”: “Google Maps”,
“author_title”: “Rice Man”,
“author_id”: “103649495941586242465”,
“author_image”: “”,
“review_text”: “Foothills Overhead Door are my go to service group. Honest and dependable. Thanks guys!!”,
“review_img_url”: “”,
“owner_answer”: “We appreciate you and your business! Joe”,
“owner_answer_timestamp”: 1666742137,
“owner_answer_timestamp_datetime_utc”: “10/25/2022 23:55:37”,
“review_link”: “Google Maps”,
“review_rating”: 5,
“review_timestamp”: 1666741261,
“review_datetime_utc”: “10/25/2022 23:41:01”,
“review_likes”: 0
“photos_count”: 11,
“google_id”: “0x87d42943bb8ebf53:0x2ee47dbde4dee479”,
“cid”: “3378963874976818297”,
“place_id”: “ChIJU7-Ou0Mp1IcReeTe5L195C4”,
“reviews_link”: “Redirecting”,
“reviews_id”: “3378963874976818297”,
“photo”: “”,
“street_view”: “”,
“working_hours_old_format”: “Monday: 8AM-5PM | Tuesday: 8AM-5PM | Wednesday: 8AM-5PM | Thursday: 8AM-5PM | Friday: 8AM-5PM | Saturday: Closed | Sunday: Closed”,
“working_hours”: {
“Monday”: “8AM-5PM”,
“Tuesday”: “8AM-5PM”,
“Wednesday”: “8AM-5PM”,
“Thursday”: “8AM-5PM”,
“Friday”: “8AM-5PM”,
“Saturday”: “Closed”,
“Sunday”: “Closed”
“other_hours”: null,
“business_status”: “OPERATIONAL”,
“about”: {
“Service options”: {
“Online estimates”: true,
“On-site services”: true
“Planning”: {
“Appointment required”: true
“range”: null,
“reviews_per_score”: {
“1”: 0,
“2”: 0,
“3”: 0,
“4”: 0,
“5”: 34
“reservation_links”: null,
“booking_appointment_link”: “Contact Foothills Overhead Doors in Jonesboro, AR”,
“menu_link”: null,
“order_links”: null,
“owner_id”: “118341862776511540210”,
“verified”: true,
“owner_title”: “Foothills Overhead Doors LLC”,
“owner_link”: “Google Maps”,
“location_link”: “Google Maps

What I'm trying to do is range over the to populate the shortcode. When I try to do this, it throws a `Error: Error building site: "C:\Users\marcl\Documents\Web Dev\Foothills Overhead Doors\content\reviews\index.html:11:3": failed to render shortcode "reviews": failed to process shortcode: "C:\Users\marcl\Documents\Web Dev\Foothills Overhead Doors\layouts\shortcodes\reviews.html:6:22": execute of template failed: template: shortcodes/reviews.html:6:22: executing "shortcodes/reviews.html" at <$reviewsData.reviews_data>: can't evaluate field reviews_data in type []interface {}`

I was thinking that I need to use bracket notation to access the inside of the array, but when I use {{ $reviewsData := $[0], it throws another error saying that the brackets are a bad character. Is there any way to do this? Since it's a remote file, I can't manipulate the format. Thanks in advance!

You can use index function to access specific array item, something like this:

{{ $reviews := getJSON “” (dict “X-API-KEY” “APIKEY”) }}

{{ $reviewsData := $ }}

{{/* Access array item, `$[0]` */}}
{{ $data_first := index $reviewsData 0 }}

{{ range $data_first }}
  {{/* .... */}}
{{ end }}

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