【发布时间】:2018-09-30 12:03:51
【问题描述】:
var data = {
food:"chicken",
list:[
{ name: "wings", qty: "25", price: "4,900", payment:"Cash" },
{ name: "lap", qty: "50", price: "9,900", payment: "Credit" }
]
}
我通过 php laravel 模型关系从 ajax 收到上述数据,我想使用 javascript 或任何库将数据转换为以下格式。
下面的数据是我们想要的。
var data = [
{ food:"chicken", name: "wings", qty:"25", price:"4,900", payment:"Cash" },
{ food:"chicken", name: "lap", qty:"50", price:"9,900", payment:"Credit" }
]
【问题讨论】:
-
请将解决问题的尝试分享为minimal reproducible example,并将其作为edit 包含在您的问题中。
标签: javascript underscore.js lodash