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 8682523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:47:58+00:00 2026-06-12T21:47:58+00:00

I am writing a test program to pull data from the Rotten Tomatoes API

  • 0

I am writing a test program to pull data from the Rotten Tomatoes API and would like to know the best approach for looping over an objects properties after using the mapping plugin. The data is pretty straightforward and is being retrieved via jquery ajax.

Here is a small part of the data:

"ratings": {
  "critics_rating": "Certified Fresh",
  "critics_score": 99,
  "audience_rating": "Upright",
  "audience_score": 91
 }

This is part of a larger mapping and I’m performing a mapping like this in the ajax callback:

self.moviedetail = ko.mapping.fromJS(data);

I realize I can do the following which is what I’m trying to optimize:

<div data-bind-"with: moviedetail">
 <ul data-bind="with: ratings">
  <li>Critics Rating: <span data-bind="text: critics_rating"></span></li>
  <li>Critics Score: <span>data-bind="critics_score"</span></li>
   etc
 </ul>
</div>

I have not determined how I could loop over each of the ratings to display them like this in some kind of data agnostic way without checking each one. Using underscore I could loop over the properties and get the values for them, but don’t know how to achieve the same thing in knockout.

The end result I’m looking for is this:

<ul>
  <li>critics_rating: Certified Fresh</li>
  <li>critics_score: 99</li>
  ....
</ul>

Notes: Per one of the answers which will definitely work, I can preprocess the data like this, however I’m looking to see if there is a way to do it on the view.

if (data.ratings!=='undefined') {
  self.ratings.removeAll();
  for(var prop in data.ratings) {
    if(data.ratings.hasOwnProperty(prop)) {
        self.ratings.push({name: prop, value: data.ratings[prop]});                         
    }
  }
}
  • 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-12T21:48:00+00:00Added an answer on June 12, 2026 at 9:48 pm

    I don’t think you can do this with knockout by default.

    You could process the data array to put the incoming data in a structure you can bind in a generic way, like:

    "ratings" : {
        [ "name": "critics_rating", "value": "Certified Fresh" ],
        [ "name": "critics_score", "value": 99 ],
        ...
    }
    

    Then use HTML like

    <ul data-bind="foreach: ratings">
        <li>
            <span data-bind="text: name"></span>:
            <span data-bind="text: value"></span>
        </li>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, so I'm writing a test program to send a vector of objects from
I am writing a test program to copy some file in Application data folder
I'm writing a simple test program to pass multidimensional arrays. I've been struggling to
So I'm writing a program to test the endianess of a machine and print
I'm writing a program similar to a diagnostic program , that runs a test
In writing Test case as I know, first step/task is to identify the Test
I am writing a test program to understand vector 's better. In one of
I am writing a small test program that gives the following xml file as
I've been writing a test case program to demonstrate a problem with a larger
This question might be a little specific but the test program im writing uses

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.