I'm faced with extracting specific keys and values from a JSON
data that contains a variety of information. Here's the snippet of the JSON
data:
"projectID": 1,
"projectName": "XXX",
"price": 0.2,
"regStart":{
"$date": "2021-12-15T16:00:00.00Z"
},
"regEnd":{
"$date": "2021-12-18T16:00:00.00Z"
},
"saleStart":{
"$date": "2021-12-20T20:00:00.00Z"
},
"saleEnd":{
"$date": "2021-12-15T20:00:00.00Z"
},
"totalRaise": 200000,
"totalSale": 50000,
"projectStatus": "Ongoing",
My goal is to extract and store only projectID, projectName, and price. However, I'm unsure how to iterate through this data and save it to my empty object.
let result = []
for(let i=0;i<data.length;i++){
let tempRes = {}
// ...no idea how to do it
result.push(tempRes);
}