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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:03:22+00:00 2026-06-06T08:03:22+00:00

I have a generated JSON file that I would like to transform. Is there

  • 0

I have a generated JSON file that I would like to transform. Is there an easy way to transform the “id”/”value” form of this JSON to a proper key/value JSON object, without using any frameworks?

 
These lines:

     "value":"chrome",
     "id":"foo"

would convert to:

  "foo": "chrome"

Input JSON:

{"row":[
    {
        "column":[
            {
                "value":"chrome",
                "id":"foo"
            },
            {
                "value":0,
                "id":"bar"
            },
            {
                "value":"baz1",
                "id":"baz"
            },
            {
                "value":0,
                "id":"legacy"
            }
        ]
    },
    {
        "column":[
            {
                "value":"firefox",
                "id":"foo"
            },
            {
                "value":0,
                "id":"bar"
            },
            {
                "value":"baz2",
                "id":"baz"
            },
            {
                "value":0,
                "id":"legacy"
            }
        ]
    }
]
}

Desired JSON:

{"row":[

    {
        "foo":"chrome",
        "bar":0,
        "baz":"baz1",
        "legacy":0
    },
    {
        "foo":"firefox",
        "bar":0,
        "baz":"baz2",
        "legacy":0
    }
]
}
  • 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-06T08:03:24+00:00Added an answer on June 6, 2026 at 8:03 am

    Here is the solution:

    var result = {"row": []}
    
    for (var i = 0; i < input["row"].length; i++) {
      var object = {};
      var column = input["row"][i]["column"];
    
      for (var j = 0; j < column.length; j++) {
        object[column[j]["id"]] = column[j]["value"];
      }
    
      result.row.push(object);
    }
    
    console.log(result);
    

    input variable refers to your initial JSON object.

    var input = {"row":[
        {
            "column":[
        ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dictionary in Python that I would like to serialize in JSON
I have a listview that's dynamically generated from a JSON file as such: $.getJSON('test2.json',
I have a set of radio buttons that are dynamically generated (via JSON call):
I have a JSON stream being generated by a server side C++ program that
I have a nested form in which I would like the form fields to
I have a Rakefile that includes this: Jeweler::Tasks.new do |gem| # ... gem.add_dependency('json') end
I have a JSON data file that is part of my application (version controlled,
I have a form that is used to upload the file and a CGI
I have a JSON object which is generated by PHP. It's an object with
I have generated a pdf file with password protection by using the following code:

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.