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

  • Home
  • SEARCH
  • 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 8964605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:37:36+00:00 2026-06-15T16:37:36+00:00

I have a JSON file that will provide data on 15 cities like so:

  • 0

I have a JSON file that will provide data on 15 cities like so:

"New York": {
    "total": 121,
    "shameless": 16,
    "honorable": 105,
    "index": 0.132
}

I have a div for every city:

<p class="pin newyork" id="New-York">
    New York
</p>

I need to parson the JSON file and identify what city it is, in this case it is New York, then get the ‘index’ associated with that city.

If the index is less than .33 it should addClass “barely”, if it is less than .66 addClass “fairly” and anything above .66 addClass “totally”. Which should look like this:

var shamelessIndex;

if (shamelessIndex < .33 ){
    $(".shamerating").addClass("barely");
}
else if (shamelessIndex < .66){
    $(".shamerating").addClass("fairly");
}
else {
    $(".shamerating").addClass("totally");
}

I have a function pulling in the data, I’m just not sure how to parse it to match the city with the DIV?

function dataStore(dataObj) {
    $.each(dataObj, function(key, value) {
        console.log(key);
        console.log(value.index);
    });
}
  • 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-15T16:37:37+00:00Added an answer on June 15, 2026 at 4:37 pm

    Assuming you are simply replacing spaces in the city name with hyphens to get the id, try this:

    $.each(dataObj, function(key, value) {
        var $city = $("#" + key.replace(' ', '-'));
        var shamelessIndex = value.shameless;
        // do stuff with shameless index here...
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If i have a php file that outputs json data with numerical keys, like
I have a generated JSON file that I would like to transform. Is there
I have a text file that contains cached data in JSON format. I'm trying
I have a json file that's like for e.g. [{fu: thejimjams, su: 232104580}, {fu:
I have a JSON file that will create my ParentModel as well as populate
I have a file that JSON statements that look like this 20110812 09:00:00:012000 INFO
I have a CSV file that I would like to use as source data
I have an external JSON file (data.json) and would like to get data from
I have a json file that I'm trying to get values out of. One
I have a JSON file that has more name value pairs than I care

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.