【发布时间】:2021-04-12 01:13:59
【问题描述】:
我有一个如下的 json 格式。我很困惑,能不能把第一个值作为key,第二个值作为key的内容?
[
{
"configSlug": "receiptStoreName",
"configContent": "The Store Name"
},
{
"configSlug": "receiptStoreAddress",
"configContent": "Cattle Street"
},
{
"configSlug": "receiptStorePhone",
"configContent": "01 123234"
},
{
"configSlug": "receiptStoreFoot1",
"configContent": "Thanks For Visiting"
}
]
预期结果:
{
"receiptStoreName": "The Store Name",
"receiptStoreAddress": "Cattle Street",
"receiptStorePhone": "01 123234",
"receiptStoreFoot1": "Thanks For Visiting"
}
谢谢你帮助我。
【问题讨论】:
-
请发布您自己编写的代码以尝试解决问题,以便我们帮助您调试它。请记住,SO 是为了帮助您解决代码中的问题,而不是为您编写代码。如果您在解决此问题时需要帮助,请研究
map()方法。 -
寻求帮助。考虑使用reduce方法
标签: javascript jquery arrays json object