如何在javascript中深度嵌套的对象数组中进行迭代?

问题描述 投票:0回答:1

如何在javascript中深度嵌套的对象数组中进行迭代?我想遍历对象的结果数组。像这样:

{
      "meta": {
        "disclaimer": "Do not rely on openFDA to make decisions 
         regarding medical care. While we make every effort to 
     ensure that data is accurate, you should assume all results are 
     unvalidated. We may limit or otherwise restrict your access to 
     the API in line with our Terms of Service.",
     "terms": "https://open.fda.gov/terms/",
     "license": "https://open.fda.gov/license/",
     "last_updated": "2019-12-14",
     "results": {
          "skip": 0,
          "limit": 1,
          "total": 504
        }
     },
       **"results": [**
       {
         "effective_time": "20190502",
          "inactive_ingredient": [
           "Inactive ingredients D&C yellow #10, FD&C yellow #6
        ]
javascript api object nested call
1个回答
0
投票

考虑到这是您的对象,您可以根据需要轻松地使用forEach()map()遍历results数组中的对象。

以下是屏幕截图作为示例:

Code

希望对您有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.