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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:24:24+00:00 2026-06-15T05:24:24+00:00

I’ve been banging my head against this for half the day today. I have

  • 0

I’ve been banging my head against this for half the day today. I have nested JSON, that I would like to be able to just grab and parse each of the nodes into a separate ol, with the node name used in the first li as the title. I can parse the response just fine and iterate through it, but changing it to separate out the nodes into blocks is where I get stuck. This is my js so far:

function parseData(obj) {
            var newId = '';
            var hashId = '#pay-data';


            $.each(obj, function(key, val) {
                if(val && typeof val === "object") {
                    $('#pay-data').append('<ol>');
                    parseData(val);
                } else {
                    console.log(key + ' - ' + val);
                    $('#pay-data').append('<li>' + key + ' - ' + val + '</li>');
                }
            });
        }

And this is a sample of the JSON:

{
"success":true,
"payAndBenefits":{
"employers":[{
    "rewards":
        {
            "totalCompensationValue":1466.95,
            "otherDeductions":141.82,
            "netPay":605.18,
            "incomeTaxes":101,
            "governmentReqd":50,
            "employerRetirementContributions":90.12,
            "employerPaidBenefits":376.83,
            "employeeRetirementContributions":102
        },
        "pay":
            {
                "paySiteURL":"https://someurl.com",
                "payPeriodEnding":"2012-09-30",
                "payDate":"2012-10-01",
                "otherDeductions":[
            {
                "description":"G T L Offset",
                "amountYTD":45,
                "amountThisPeriod":6
            },
            {
                "description":"Before Tax Dent",
                "amountYTD":-900,
                "amountThisPeriod":-147.82
            },
            {
                "description":"Checking deposit",
                "amountYTD":-6668,
                "amountThisPeriod":-605.18
            }
        ],
        "netPayYTD":6668,
        "netPayThisPeriod":605.18,
        "incomeTaxesDeductions":[
            {
                "description":"Federal Income Tax",
                "amountYTD":-909,
                "amountThisPeriod":-101
            }
        ],
        "grossPayYTD":9800,
        "grossPayThisPeriod":1000,
        "governmentRequiredDeductions":[
            {
                "description":"Social Security Tax",
                "amountYTD":-450,
                "amountThisPeriod":-50
            }
        ],
        "employeeRetirementPlanContribDeductions":[
            {
                "description":"401(k)",
                "amountYTD":-918,
                "amountThisPeriod":-102
            }
        ],
        "earnings":[
            {
            "description":"Regular",
            "amountYTD":9000,
            "amountThisPeriod":1000
            },
            {
                "description":"Vacation",
                "amountYTD":800,
                "amountThisPeriod":null
            }
        ]
    },
    "employerName":"Company Name",

It seems like I should be able to object.name in here somewhere, but I’m totally stuck.

  • 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-15T05:24:26+00:00Added an answer on June 15, 2026 at 5:24 am

    I guess you want something like this.

    function parseData(obj, targetDOMElement) {
    
      $.each(obj, function(key, val) {
    
        if(val && typeof val === "object") {
    
          var newTarget = $('<ol>'); // create the new list item
          newTarget.append('<li>' + key + '</li>'); // append the title as you wanted
          targetDOMElement.append(newTarget);  // add it to the target container
          parseData(val, newTarget); // parse the children and set the created list as the new target
    
        } else {
    
          // or just add the key-value pair to the target
          targetDOMElement.append('<li>' + key + ' - ' + val + '</li>');
    
        }
    
      });
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I would like to run a str_replace or preg_replace which looks for certain words
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.