【发布时间】:2021-06-28 19:59:51
【问题描述】:
在这里,我包含了我的示例代码。我想将数据插入(推送)到我的多维 json。
const answers = [
{ id: "1", text: "192.168.1.1" },
{ id: "2", text: "127.0.0.1", correct: true },
{ id: "3", text: "209.85.231.104" },
{ id: "4", text: "66.220.149.25" },
];
我想将 { id: "5", text: "66.220.149.20" }, 之类的元素插入到最后一个位置。 最终结果应该是这样的
const answers = [
{ id: "1", text: "192.168.1.1" },
{ id: "2", text: "127.0.0.1", correct: true },
{ id: "3", text: "209.85.231.104" },
{ id: "4", text: "66.220.149.25" },
{ id: "5", text: "66.220.149.20" }
];
如何通过 react-native 实现多维 json 数据?或者可以这样做吗?
【问题讨论】:
-
这里没有 JSON。 JSON 是一种文本格式。见What is the difference between JSON and Object Literal Notation?。此外,您已经展示了数据,但没有展示您自己解决问题的尝试。提示:这里显示的数组是一维的。它是一个对象数组。
标签: javascript json react-native