【发布时间】:2021-03-02 10:56:12
【问题描述】:
这是我从 API 得到的实际响应,我想转换下面的 JSON 格式
发件人:
"data": [
[
{
"isFile": "true",
"fileType": "image",
"filesize": 100793,
"filename": "attachment_0.png",
}
],
[
{
"isFile": "true",
"fileType": "image",
"filesize": 6343078,
"filename": "attachment_1.png"
}
]
]
收件人:
"data": [
{
"isFile": "true",
"fileType": "image",
"filesize": 100793,
"filename": "attachment_0.png",
},
{
"isFile": "true",
"fileType": "image",
"filesize": 6343078,
"filename": "attachment_1.png"
}
]
如何移除 Object 之间的数组。
【问题讨论】:
-
先解析然后你可以在数据上使用
flat? -
您的 JSON 无效。
"filename": "attachment_0.png",是错误的。不允许使用逗号。"data":也是错误的。你不能从属性开始。
标签: javascript arrays json react-native