【发布时间】:2022-02-15 18:37:45
【问题描述】:
我需要将数组中的所有键都转换为大写。用户将上传一个excel,所有工作表分别读入数组例如:检查细节,配料,菜单和甜点是excel中的不同工作表。
当前 JSON:
[
[
"filename",
"details.xlsx"
],
[
"Check Details",
[
{
"Outdated Label": "Outdated Label1",
"Outdated Value": "Outdated Value"
},
{
"Outdated Label": "Outdated Label2",
"Outdated Value": "Outdated Value2"
},
{
"Outdated Label": "Outdated Label3",
"Outdated Value": "Outdated Value3"
},
{
"Outdated Label": "Outdated Label4",
"Outdated Value": "Outdated Value4"
}
]
],
[
"ingredient",
[
{
"ingredient Id": "1",
"ingredient Code": "IG01",
"ingredient Label": "Recipe 1"
},
{
"ingredient Id": "2",
"ingredient Code": "IG02",
"ingredient Label": "Secret Recipe"
},
{
"ingredient Id": "4",
"ingredient Code": "IG04",
"ingredient Label": "Chef special"
},
{
"ingredient Id": "3",
"ingredient Code": "IG03",
"ingredient Label": "Today special"
}
]
],
[
"menu",
[
{
"Item Menu Id": "M01",
"Item": "Pizza"
},
{
"Item Menu Id": "M02",
"Item": "Hotdogs"
},
{
"Item Menu Id": "M03",
"Item": "French Fries"
}
]
],
[
"Desserts",
[
{
"Menu Item Id": "DRT01",
"Item": "Roasted strawberry crumble"
},
{
"Menu Item Id": "DRT01",
"Item": "Apple and butterscotch pie"
}
]
]
]
预期的 JSON:
[
[
"filename",
"details.xlsx"
],
[
"Check Details",
[
{
"OUTDATED LABEL": "Outdated Label1",
"OUTDATED VALUE": "Outdated Value"
},
{
"OUTDATED LABEL": "Outdated Label2",
"OUTDATED VALUE": "Outdated Value2"
},
{
"OUTDATED LABEL": "Outdated Label3",
"OUTDATED VALUE": "Outdated Value3"
},
{
"OUTDATED LABEL": "Outdated Label4",
"OUTDATED VALUE": "Outdated Value4"
}
]
],
[
"ingredient",
[
{
"INGREDIENT ID": "1",
"INGREDIENT CODE": "IG01",
"INGREDIENT LABEL": "Recipe 1"
},
{
"INGREDIENT ID": "2",
"INGREDIENT CODE": "IG02",
"INGREDIENT LABEL": "Secret Recipe"
},
{
"INGREDIENT ID": "4",
"INGREDIENT CODE": "IG04",
"INGREDIENT LABEL": "Chef special"
},
{
"INGREDIENT ID": "3",
"INGREDIENT CODE": "IG03",
"INGREDIENT LABEL": "Today special"
}
]
],
[
"menu",
[
{
"ITEM MENU ID": "M01",
"ITEM": "Pizza"
},
{
"ITEM MENU ID": "M02",
"ITEM": "Hotdogs"
},
{
"ITEM MENU ID": "M03",
"ITEM": "French Fries"
}
]
],
[
"Desserts",
[
{
"MENU ITEM ID": "DRT01",
"ITEM": "Roasted strawberry crumble"
},
{
"MENU ITEM ID": "DRT01",
"ITEM": "Apple and butterscotch pie"
}
]
]
]
注意:所有键都是动态的,因为它是从 excel 上传的,可以是任何东西。
【问题讨论】:
-
到目前为止你尝试过什么?你被困在哪里了?
-
另请注意,
array(s) 没有keys...objects有...!!!
标签: javascript angular typescript