我有一个数据集,它是一个对象数组,每个对象都是另一个对象,里面有一个数组。我正在尝试将所有内容展平为最里面的对象的单个数组,而没有中间层对象的键。我曾尝试使用 pluck 功能,但我似乎无法达到我所追求的目标。下面的例子。
输入:
[
{
"1234": [
{
"store": "07",
"category": "1234",
"account": "987"
},
{
"store": "07",
"category": "1234",
"account": "555"
},
{
"store": "07",
"category": "1234",
"account": "555"
}
]
},
{
"567": [
{
"store": "07",
"category": "567",
"account": "987"
},
{
"store": "07",
"category": "567",
"account": "555"
},
{
"store": "07",
"category": "567",
"account": "555"
}
]
}
]
输出:
[
{
"store": "07",
"category": "1234",
"account": "987"
},
{
"store": "07",
"category": "1234",
"account": "555"
},
{
"store": "07",
"category": "1234",
"account": "555"
},
{
"store": "07",
"category": "567",
"account": "987"
},
{
"store": "07",
"category": "567",
"account": "555"
},
{
"store": "07",
"category": "567",
"account": "555"
}
]