0

I have the following JSON object:

{
    "_id": "123",
    "name": "aa",
    "description": "sdweok",
    "category": "11123",
    "tags": ["aasdsd"],
    "extraData": {
        "brand" : "oksdf",
        "quantity": "2003",
        "typeOfQuantity": "gr",
        "type": "sdqwef"

    }

}

What I want to do is change the _id with id. I use the following code:

 product = product.map(function (obj) {
   var output = {};
   output["id"] = obj._id;
   output["name"] = obj.name;
   output["description"] = obj.description;
   output["category"] = obj.category;
   output["tags"] = obj.tags;
   output["extraData"] = obj.extraData;
   return output;
 });

.map() however accepts only lists or arrays. What can I do?

Giannis
  • 312
  • 2
  • 5
  • 16

0 Answers0