Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9129607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:47:20+00:00 2026-06-17T07:47:20+00:00

Given a JSON response from my server as follows: { products : [ {

  • 0

Given a JSON response from my server as follows:

{
"products" : [
    {
        "Product" : {
            "id" : "122",
            "name" : "product X",
            "price" : "19.99",
        },
        "Picture" : [
            {
                "product_id" : "122",
                "id" : "145",
            },
            {
                "product_id" : "122",
                "id" : "146",
            },
            {
                "product_id" : "122",
                "id" : "147",
            }
        ]
    }
]
}

I will create a backbone model that will be passed to a backbone View. In my View’s template I can access the product’s name with:

 <%= Product.name %>

and all works as expected. But lets say I want to get the id of the first Picture. I tried:

<%= Picture.0.id %>

But I get the following error in my console:

Uncaught SyntaxError: Unexpected number 

So in a nutshell how do I access the properties of the various pictures associated with my product from the product template. I am using underscore templates if that matters.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:47:22+00:00Added an answer on June 17, 2026 at 7:47 am

    The normal javascript array indexer syntax [index] will do the trick:

    <%= Picture[0].id %>
    

    Edit: Underscore accepts any old javascript inside the <% %> tags, so if you want to check whether an array is empty, you can do so using the standard _.isEmpty method:

    <% if(!_.isEmpty(Picture)) { %>
       <%= Picture[0].id %>
    <% } else { %>
       No picture
    <% } %>
    

    Or any other javascript construct you prefer. See docs for more info.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting a JSON response from the server and i have to loop through
I am currently using an InpuStream to get a JSON response from my server.
I get the following NSDictionary when I parse a JSON response from my server:
Given the following array of json objects: var items = [ {id:1, parentId:0, name:'item1'},
I have to get response text from a resourceindex page as JSON object. When
I'm using JSON.NET to parse a JSON reponse from openexhangerates.org server side using .NET.
I'm creating an app that fetches back a Json response from a webservice. The
I am using PHP CURL to fetch data from a server. The response can
I’m trying to write a response from a Solr server to a CSV file.
Given the following JSON data: [ { pk: 2, model: corkboard.announcement, fields: { body:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.