简体   繁体   English

从数组节点中提取所有 object 个值

[英]Extract all object values from array node

I got an array with objects and they're values.我得到了一个包含对象的数组,它们是值。

Is it possible to extract all object values without doing this every time: Array[objnumber].value ?是否可以提取所有 object 值而无需每次都这样做: Array[objnumber].value

Here is how it looks in mongoDB: https://gyazo.com/a4a6702ef0546609ea231de299ee62fd这是它在 mongoDB 中的样子: https://gyazo.com/a4a6702ef0546609ea231de299ee62fd

Here is what data looks like这是数据的样子

{
   "date":[
      {
         "title":"Unavaible",
         "start":"2020-05-19",
         "end":"2020-05-22"
      },
      {
         "title":"Unavaible",
         "start":"2020-05-28",
         "end":"2020-05-29"
      },
      {
         "title":"Unavaible",
         "start":"2020-05-29",
         "end":"2020-05-31"
      }
   ]
}

I just used JSON.stringify to accomplish it.我只是使用 JSON.stringify 来完成它。

Code:代码:

const responses = response.data.date
        const stringify = JSON.stringify(responses);
        this.setState({
          undates:[stringify]
        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM