解析 api 响应

Parsing an api response

我想解析此 api 响应以获取图像 url 我发现它实际上有点令人困惑,因为我是 apis 的新手。

    {
      "id": "123",
      "item": [
        {
          "picture": {
            "type_id": "2",
            "url": [
              "./img.jpg"
            ],
            "is_in_description": 0,
            "gallery": {
              "url": "",
              "url_id": ""
            },
            "layout_id": "2",
            "variation_name": ""
          },
          "lister_id": "12345"
        }
      ]
    }

这是我获取 api 的代码,任何人都可以帮助我吗

fetch(url2,{
          method: 'GET'
        })
        .then((response)=> response.json())
        .then((responseJson) => {
          const newImg = responseJson.item.map( => {
            return{
              const img = 
            };
          })
          const newState = Object.assign({}, this.state, {
            items: newItems
          });

          console.log(newState);
          this.setState(newState);
        })
        .catch((error) => {
          console.log(error)
        });

使用map方法解析为

var x =   {
      "id": "123",
      "item": [
        {
          "picture": {
            "type_id": "2",
            "url": [
              "./img.jpg"
            ],
            "is_in_description": 0,
            "gallery": {
              "url": "",
              "url_id": ""
            },
            "layout_id": "2",
            "variation_name": ""
          },
          "lister_id": "12345"
        }
      ]
    }

x.item.map(data=>{console.log(data.picture.url)}) //hope you need the url object