我有这个数组:
aItems = [{
"PropertyA": "apple",
"PropertyB": "banana",
"PropertyC": "dog",
"PropertyD": "hotdog",
"PropertyE": "coldcat",
"PropertyF": "Y",
"PropertyG": "N"
},
...,
{
"PropertyA": "this",
"PropertyB": "is",
"PropertyC": "json",
"PropertyD": "code",
"PropertyE": "wow",
"PropertyF": "N",
"PropertyG": "N"
}]
Run Code Online (Sandbox Code Playgroud)
我想使用lodash来获得这个结果:
aItems = [{
"propertyA": "apple",
"propertyB": "banana",
"propertyC": "dog",
"propertyD": "hotdog",
"propertyE": "coldcat",
"propertyNEW": true,
"propertyG": false
},
...,
{
"propertyA": "this",
"propertyB": "is",
"propertyC": "json",
"propertyD": "code",
"propertyE": "wow",
"propertyNEW": false,
"propertyG": false
}]
Run Code Online (Sandbox Code Playgroud)
我希望将每个属性名称与其他名称一起映射,并更改某些特定属性的值.我可以用lodash做吗?
我想重命名obj中的键,由此:
objs = {
one: { description: "value", amount: 5, value: { description: "value desc", identifier: "some text"} },
two: { description: "value", amount: 5, value: { description: "value desc", identifier: "some text"} }
}
Run Code Online (Sandbox Code Playgroud)
进入这个:
objs = {
one: { original_description: "value", amount: 5, value: { description: "value desc", identifier: "some text"} },
two: { original_description: "value", amount: 5, value: { description: "value desc", identifier: "some text"} }
}
Run Code Online (Sandbox Code Playgroud) 我从API获得以下数据数组。
[
{
"barCode": "31568308949"
"itemDesc": "ASHTON-250"
"permPrice": 19.99
}
]
Run Code Online (Sandbox Code Playgroud)
预期结果如下。
[
{
"Bar Code": "31568308949"
"Item Description": "ASHTON-250"
"Prem Price": 19.99
}
]
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我实现这一目标。提前致谢。