Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
How to iterate json consists of array elements

I am getting this object :

"contributionData": {
        "Contribution 1": [
            4,
            4
        ],
        "Contribution 2": [
            1,
            1
        ]
    }

I want this kind of table after iteration.

contribution1 |  4  |  4  |
contribution2 |  1  |  1  |

I've converted it to array :

        let result = [];

        for(let i in this.state.testData) {
            result.push([i, this.state.testData[i]]);
        }

console log after converting it to array

   <tr>
       <td>{this.state.result}</td>
   </tr>

I want to fill this data in table format I am working on React js, I want to do this in javascript.

Any help would be appreciated.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try this one.

let result = []
let data = {
  "Contribution 1": [
            4,
            4
        ],
        "Contribution 2": [
            1,
            1
        ]
}
Object.keys(data).map((item) => {result.push([item].concat(data[item]))})
console.log(result);
...
{
    results.map(item, i)=> (
      <tr key={i}>
          {item.map(val, index) => (
            <td key={"row" + index}>{val}</td>
          )}
      </tr>
    )
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!