Eliminate an element from a JSON array by utilizing its unique identifiers

I need help with extracting specific values from an array. The array looks like this:

{
"123456": {
    "name": "tom",
    "projects": {
        "987654": {
        "cli": "abcd",
        "org": "123456",
        "cli_e": "abcd",
        "pro": "abcd",
        "status": "6"
        }
      }
   }
},
{
"654321": {
    "name": "jerry",
    "projects": {
        "123": {
        "cli": "xyz",
        "org": "000",
        "cli_e": "xyz",
        "pro": "xyz",
        "status": "3"
        }
      }
   }
}

My goal is to extract the following values:

{
  "cli": "abcd",
  "org": "123456",
  "cli_e": "abcd",
  "pro": "abcd",
  "status": "6"
},
{
  "cli": "xyz",
  "org": "000",
  "cli_e": "xyz",
  "pro": "xyz",
  "status": "3"
}

Is there a way to achieve this extraction?

Answer №1

Answer discovered thanks to the expertise of hsz

let result = [];
for (let key in inputData) {
  for (let projectKey in inputData[key].projects) {
    result.push(inputData[key].projects[projectKey]);
  }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to add content to a dynamically generated div element within a for loop using jQuery?

I have been experimenting with a coding challenge and I need some assistance achieving my desired outcome. At the beginning, I had an array called skillsArray with 5 values, which led me to create specific javascript code for each value: $('# ...

Animating the dimensions of objects in THREEjs

In my project using THREE.js, I am aiming to create a captivating animation where an object gradually shrinks into nothingness. After exploring solutions on Three.js - Animate object size, I found methods to adjust the size of an object. However, the chan ...

A guide on verifying the username, password, and chosen role from a database through the use of javascript/ajax or alternative validation methods

If the user's name, password, or role is incorrect, I want to display an error message using validations like AJAX/JavaScript. index.php <html> <head> </head> <body> <style> body { wi ...

Passing multiple arguments in the form of an array of C pointers, *

Currently grappling with the challenge of converting the output from one of my functions, which is in the format char fileParameters[10][10], into the format of *argv[] to use as input for another function that also requires the same structure of argv. The ...

Transfer the text from one cell and insert it into the "neighbor" cell of a different column when the content is editable

present situation: Clicking on a row fills the entire row of another column, instead of just filling a single row. <p class="p-of-that" v-html="thatText" contenteditable @click="writeThat(myArr, $event)" ></p& ...

Waiting for file changes in JavaScript using AJAX

Currently, I am in the process of developing a website to manage my Raspberry Pi robot. Through a .py script called GPS.py, I am able to control two stepper motors by executing the following command: sudo ./GPS.py forward 100 30 The first argument specif ...

Popovers in Bootstrap 4 do not have clickable Custom Forms

I find it strange that in Bootstrap 4, only custom forms are not clickable in the Bootstrap popover. It's interesting how default forms in Bootstrap 4 work just fine. Any suggestions on how to resolve this issue? Below is my code. Thank you for you ...

jQuery enables the creation of fresh form fields

Currently, I am working on a form that initially consists of 2 text input fields. The typical use case involves the user entering a number in one field and their name in the other. Following this, the page updates itself without reloading. However, there a ...

Show the present time pulled from the timer

I am in possession of a countdown timer that starts at zero and counts up to 100. The timer displays the count in a p tag with the ID of countdowntimer. I am attempting to show the current time when I click a button while the timer is running. Additional ...

Retrieve the JavaScript variable `window.myvariable` within the ASP code-behind of a child form

In my scenario, I am utilizing a parent form that initiates a child form through the following javascript code in order to transmit a json object. var w = window.open("childForm.aspx"); w.myJsonObj = myJSONObject; I am currently seeking a ...

Map markers for Google Places search not displaying properly

I am currently working on a demo to showcase the functionality of a future search feature. My goal is to query Google for information based on an address or area and then display the area bounds along with nearby places. To achieve this, I am utilizing too ...

Set the background color of the list item to a color that I choose

I am dealing with colors on my server side. I have a list structure in place. When loading the jsp, I need to assign specific colors to specific list items. The color from the server side may change and the assignment of colors to list items depends on the ...

Guide on Incorporating Coffeescript into the Node.js Blueprint Framework

Have you checked out Skeleton (https://github.com/dstroot/skeleton) yet? It appears to be a robust framework for node.js, offering all the middleware you need. However, it seems to lack support for coffee script. How can we incorporate it into our project? ...

Guide on converting retrieved data from MySQL into JSON using PHP

I'm currently working on converting data retrieved from a MySQL database into JSON format using PHP. Below is the code snippet I am utilizing: try { $statement = $db->prepare($query); $result = $statement->execute($query_params); $ ...

Unable to establish a remote connection to the dlib webserver, but local host connection is functioning

Currently, I am in the process of building a front end using HTML and JavaScript with a C++ backend to handle all calculations. The two are connected through an integrated dlib web server that manages requests. When the frontend requests data, it looks lik ...

What is the best way to link JavaScript files from a Grails plugin in a separate Grails application?

I have developed a unique plugin that offers multiple Grails controllers and domain objects. Additionally, I have created several AngularJS UI components that I wish to utilize in various other projects. These specific files are located within the web-app ...

Updating a MongoDB document using only the data from checked checkboxes

Imagine having data structured like this: _id:60e2edf7014df85fd8b6e073 routineName:"test" username: "tester" monday:[{ _id: 60e430d45395d73bf41c7be8 exercise: "a" }{ _id: 60e4329592e ...

Is it the same item in one situation, but a completely different item in another?

I am currently investigating the behavior of objects in JavaScript, particularly when it comes to copying one object onto another. It seems that sometimes they behave as if they are the same object, where modifying one also modifies the other. Many resourc ...

Using Vue.js to dynamically append router links with JavaScript

let link = `<router-link :to="{name : 'profile' , params : { slug : ${response.data.nickname} }}"> <img src="${response.data.avatar}" class="card__image"> </router-link>`; $('body').appen ...

Troubleshooting: jQuery toggle not functioning as expected

<div class="content" id="current"> <div id="loader" style="display:none;"><img src="/images/loader.gif" alt="" /></div> </div> I have a Box element in the code above, and when I click on a submit button, I want a loader i ...