I have an array like
{
"Count": 3,
"Items": [
{
"prod_price": {
"N": "100"
},
"prod_name": {
"S": "Laptop"
},
"prod_Id": {
"N": "3"
}
},
{
"prod_price": {
"N": "1000"
},
"prod_name": {
"S": "Mouse"
},
"prod_Id": {
"N": "2"
}
},
{
"prod_price": {
"N": "2000"
},
"prod_name": {
"S": "Keyboard"
},
"prod_Id": {
"N": "1"
}
}
],
"ScannedCount": 3
}
I need the output like
{
"Count": 3,
"Items": [
{
"prod_price" : "100",
"prod_name": "Laptop",
"prod_Id": "3"
},
{
"prod_price" : "1000",
"prod_name": "mouse",
"prod_Id": "2"
},
{
"prod_price" : "2000",
"prod_name": "keyboard",
"prod_Id": "1"
},
],
"ScannedCount": 3
}
I am trying to get this output but no able to get this can you help me for this.
var items=data['Items'];
var itemresult={};
itemvalues={};
for(var attributename in items){
for(var itemattribute in items[attributename]){
for(var key in items[attributename][itemattribute]){
console.log(itemvalues);
itemresult.attributename.itemattribute=items[attributename][itemattribute][key];
}
}
I am new to node.js and don't how to work with the for loops exactly. I have tried my best, as if in php we have the for-each loop so we can skip the index value.
If I can get that so this conversion will be done. I don't know how to get that, can you please help me to find the solution?
I know there can be some problem because I don't know the exact syntax so any help would be appreciated. Thank you