I am using node.js
I have this array of RowDataPacket objects below;
{
_ID: 4,
_NAME: "Switch4",
_CASE_COUNTER: 1,
_CASE_ID: 1
},
{
_ID: 4,
_NAME: "Switch4",
_CASE_COUNTER: 2,
_CASE_ID: 2
}
{
_ID: 4,
_NAME: "Switch4",
_CASE_COUNTER: 3,
_CASE_ID: 3
}
I would like to compress this array of RowDataPacket objects into a single object. After compression, it will look like this:
{
_ID: 4,
_NAME: "Switch4",
_CASE_COUNTER: 1,
_CASE_ID: 1,
_CASE_COUNTER: 2,
_CASE_ID: 2,
_CASE_COUNTER: 3,
_CASE_ID: 3
}
The keys _IDand _NAMEhave the same value in the array of RowDataPacket objects. Other keys will have different meanings. How can this be done in node.js v4.7.x?
EDIT: This is not an array of json objects, as stated in the original question. This is an array of RowDataPacket objects that is the result of a MySQL query.
user6064424
source
share