我正在开发一个React应用程序,从路由中获取JSON响应,该路由基本上是JSON对象的列表。
现在我想根据JSON对象中的另一个字段为每个JSON对象添加一个字段:
这是我的响应:
{
messages: [
{
msgId: "2021082111010755885",
interfaceId: 5,
status: "QUEUED",
createdAt: "2021-08-21 11:01:07.89554",
modifiedAt: "2021-08-21 11:01:07.89554",
count: 0,
},
{
msgId: "2021082012204615964",
interfaceId: 5,
status: "QUEUED",
createdAt: "2021-08-20 12:20:46.187297",
modifiedAt: "2021-08-20 12:31:06.622",
count: 5,
},
{
msgId: "2021082012204575430",
interfaceId: 5,
status: "QUEUED",
createdAt: "2021-08-20 12:20:46.187297",
modifiedAt: "2021-08-20 12:27:06.473",
count: 3,
},
{
msgId: "2021082012204613152",
interfaceId: 5,
status: "QUEUED",
createdAt: "2021-08-20 12:20:46.187297",
modifiedAt: "2021-08-20 12:28:06.517",
count: 3,
},
];
}
现在我想要插入一个名为
mString
的字段,其值为状态(status
)加上字母"A",其中状态(status
)来自同一对象。我想将它插入到上述数组中的每个对象中。我该如何做?