【问题标题】:How to navigate through the nested JSON file using index in javascript?如何使用 javascript 中的索引浏览嵌套的 JSON 文件?
【发布时间】:2017-06-01 06:18:10
【问题描述】:

我对编码很陌生,目前,我正在编写一个 React 本机项目。对不起,如果问题太简单了。我尝试了很多导航方法,但都失败了。 我有一个 JSON 文件,数据如下。

{
"values" : {
      "EquityTechnology": {
        "_figure": [
          9.138790534659202
        ],
        "ICICIPrudentialTechnologyFundGrowth": {
          "_figure": [
            10.6484932862722
          ]
        },
        "Franklin Infotech Fund-Growth": {
          "_figure": [
            7.96902834459266
          ]
        },
        "Birla Sun Life New Millenium Fund - Growth - Regular Plan": {
          "_figure": [
            8.79884997311275
          ]
        },
        "SBI IT FUND - REGULAR PLAN - GROWTH": {
          "_figure": [
            null
          ]
        }
      },
      "Equity - SmallCap": {
        "_figure": [
          14.0064060591969
        ],
        "HDFC Small Cap Fund - Regular Growth Plan": {
          "_figure": [
            null
          ]
        },
        "Reliance Mid & Small Cap Fund -Growth Plan -Growth Option": {
          "_figure": [
            11.8481966627509
          ]
        },
        "Franklin India Smaller Companies Fund-Growth": {
          "_figure": [
            15.3302065566009
          ]
        },
        "Sundaram S.M.I.L.E.Fund-Growth": {
          "_figure": [
            11.754220292209
          ]
        },
        "SBI Magnum MIDCAP FUND - REGULAR PLAN - GROWTH": {
          "_figure": [
            14.9351631127958
          ]
        },
        "Birla Sun Life Small & Midcap Fund - GROWTH": {
          "_figure": [
            12.3666676648488
          ]
        },
        "L&T Emerging Businesses Fund - Regular Plan - Growth Option": {
          "_figure": [
            null
          ]
        },
        "Canara Robeco Emerging Equities - Regular Plan - GROWTH": {
          "_figure": [
            14.6579568171628
          ]
        },
        "Reliance Small Cap Fund - Growth Plan - Growth Option": {
          "_figure": [
            15.0019513606657
          ]
        },
        "DSP BlackRock Micro Cap Fund - Regular - Growth": {
          "_figure": [
            16.1568860065413
          ]
        }
      },
      "Equity - Pharma": {
        "_figure": [
          12.966782129169834
        ],
        "SBI PHARMA - REGULAR PLAN -GROWTH": {
          "_figure": [
            14.9918670876748
          ]
        },
        "UTI Pharma & Healthcare Fund-Growth Option": {
          "_figure": [
            11.2119667676491
          ]
        },
        "Reliance Pharma Fund-Growth Plan-Growth Option": {
          "_figure": [
            12.6965125321856
          ]
        }
      },
      "Equity - MultiCap": {
        "DSP BlackRock Equity Fund - Regular Plan - Growth": {
          "_figure": [
            8.32832307169916
          ]
        },
        "DSP BlackRock Opportunities Fund-Regular Plan - Growth": {
          "_figure": [
            9.72369143832476
          ]
        },
        "MOSt Focused Multicap 35-Regular Plan-Growth Option": {
          "_figure": [
            null
          ]
        },
        "Reliance Equity Opportunities  Fund-Growth Plan-Growth Option": {
          "_figure": [
            9.79339882843478
          ]
        },
        "L&T Equity Fund-Regular Plan-Growth Option": {
          "_figure": [
            null
          ]
        },
        "IIFL India Growth Fund -Regular Plan - Growth": {
          "_figure": [
            null
          ]
        },
        "SBI Magnum Multicap Fund - REGULAR PLAN -Growth Option": {
          "_figure": [
            10.1704693596904
          ]
        },
        "Kotak Select Focus Fund - Growth": {
          "_figure": [
            10.7785458258239
          ]
        },
        "HDFC Equity Fund - Growth Option": {
          "_figure": [
            8.29168295966879
          ]
        },
        "Franklin India Flexi Cap Fund-Growth Plan": {
          "_figure": [
            9.52777086776355
          ]
        },
        "_figure": [
          9.998290130663644
        ],
        "Franklin India High Growth Companies Fund - Growth Plan": {
          "_figure": [
            12.0111958711599
          ]
        },
        "Birla Sun Life Equity Fund - Growth - Regular Plan": {
          "_figure": [
            10.5597033707683
          ]
        },
        "ICICI Prudential Value Discovery Fund - Growth": {
          "_figure": [
            12.494420125849
          ]
        },
        "Axis Equity Fund - Growth": {
          "_figure": [
            8.30198971811754
          ]
        }
      },
      "Equity - FMCG": {
        "_figure": [
          12.9391809175777
        ],
        "SBI FMCG FUND - REGULAR - GROWTH": {
          "_figure": [
            null
          ]
        },
        "ICICI Prudential FMCG Fund - Growth": {
          "_figure": [
            12.9391809175777
          ]
        }
      },
      "Equity - Banking": {
        "_figure": [
          7.756301964533782
        ],
        "UTI Banking Sector Fund-Income Option": {
          "_figure": [
            4.48544488820235
          ]
        },
        "Kotak Banking ETF": {
          "_figure": [
            null
          ]
        },
        "Birla Sun Life Banking and Financial Services Fund - Regular Plan - Growth": {
          "_figure": [
            null
          ]
        },
        "R*Shares Bank BeES": {
          "_figure": [
            null
          ]
        },
        "Reliance Banking Fund-Growth Plan-Growth Option": {
          "_figure": [
            8.2686147173821
          ]
        },
        "SBI BANKING & FINANCIAL SERVICES FUND - REGULAR PLAN - GROWTH": {
          "_figure": [
            null
          ]
        },
        "ICICI Prudential Banking and Financial Services Fund -  Growth": {
          "_figure": [
            11.0147287026105
          ]
        },
        "UTI Banking Sector Fund-Growth Option": {
          "_figure": [
            7.25641954994018
          ]
        }
      },
      "Gold Fund": {
        "R*Shares Gold BeES": {
          "_figure": [
            null
          ]
        },
        "_figure": [
          4.0762242905284065
        ],
        "HDFC Gold Exchange Traded Fund": {
          "_figure": [
            6.03459415600124
          ]
        },
        "SBI GOLD EXCHANGE TRADED SCHEME": {
          "_figure": [
            6.14783904734468
          ]
        },
        "KOTAK GOLD ETF": {
          "_figure": [
            -3.40119263557552
          ]
        },
        "Kotak Gold Fund Growth": {
          "_figure": [
            5.61706623223513
          ]
        },
        "Axis Gold ETF": {
          "_figure": [
            5.9828146526365
          ]
        }
      }
      }
}

我想使用索引浏览 JSON,因为数据将是动态的,并且名称可能会随着时间而改变。例如,我应该怎么做才能访问“SBI PHARMA - 常规计划 -GROWTH”的“_figure”下的“14.9918670876748”,而后者又位于“Equity - Pharma”下。我想检索所有项目的“_figure”。我试过 for..in 循环,但它只返回嵌套对象的索引。有什么方法可以使用索引浏览 JSON 文件?

提前谢谢你。

抱歉英语不好。

【问题讨论】:

  • 你为什么首先使用对象然后使用数组来达到这个目的?
  • 您要访问所有数字吗?
  • 嗨,Nadir,我想访问所有数据。 JSON 数据以这种结构提供给我。
  • 把所有的图都重调成一个数组可以吗?
  • 是的,没问题,Nadir。

标签: javascript json react-native


【解决方案1】:
var rObj = {
"values" : {
      "EquityTechnology": {
        "_figure": [
          9.138790534659202
        ],
        "ICICIPrudentialTechnologyFundGrowth": {
          "_figure": [
            10.6484932862722
          ]
        },
        "Franklin Infotech Fund-Growth": {
          "_figure": [
            7.96902834459266
          ]
        },
        "Birla Sun Life New Millenium Fund - Growth - Regular Plan": {
          "_figure": [
            8.79884997311275
          ]
        },
        "SBI IT FUND - REGULAR PLAN - GROWTH": {
          "_figure": [
            null
          ]
        }
      },
      "Equity - SmallCap": {
        "_figure": [
          14.0064060591969
        ],
        "HDFC Small Cap Fund - Regular Growth Plan": {
          "_figure": [
            null
          ]
        },
        "Reliance Mid & Small Cap Fund -Growth Plan -Growth Option": {
          "_figure": [
            11.8481966627509
          ]
        },
        "Franklin India Smaller Companies Fund-Growth": {
          "_figure": [
            15.3302065566009
          ]
        },
        "Sundaram S.M.I.L.E.Fund-Growth": {
          "_figure": [
            11.754220292209
          ]
        },
        "SBI Magnum MIDCAP FUND - REGULAR PLAN - GROWTH": {
          "_figure": [
            14.9351631127958
          ]
        },
        "Birla Sun Life Small & Midcap Fund - GROWTH": {
          "_figure": [
            12.3666676648488
          ]
        },
        "L&T Emerging Businesses Fund - Regular Plan - Growth Option": {
          "_figure": [
            null
          ]
        },
        "Canara Robeco Emerging Equities - Regular Plan - GROWTH": {
          "_figure": [
            14.6579568171628
          ]
        },
        "Reliance Small Cap Fund - Growth Plan - Growth Option": {
          "_figure": [
            15.0019513606657
          ]
        },
        "DSP BlackRock Micro Cap Fund - Regular - Growth": {
          "_figure": [
            16.1568860065413
          ]
        }
      },
      "Equity - Pharma": {
        "_figure": [
          12.966782129169834
        ],
        "SBI PHARMA - REGULAR PLAN -GROWTH": {
          "_figure": [
            14.9918670876748
          ]
        },
        "UTI Pharma & Healthcare Fund-Growth Option": {
          "_figure": [
            11.2119667676491
          ]
        },
        "Reliance Pharma Fund-Growth Plan-Growth Option": {
          "_figure": [
            12.6965125321856
          ]
        }
      },
      "Equity - MultiCap": {
        "DSP BlackRock Equity Fund - Regular Plan - Growth": {
          "_figure": [
            8.32832307169916
          ]
        },
        "DSP BlackRock Opportunities Fund-Regular Plan - Growth": {
          "_figure": [
            9.72369143832476
          ]
        },
        "MOSt Focused Multicap 35-Regular Plan-Growth Option": {
          "_figure": [
            null
          ]
        },
        "Reliance Equity Opportunities  Fund-Growth Plan-Growth Option": {
          "_figure": [
            9.79339882843478
          ]
        },
        "L&T Equity Fund-Regular Plan-Growth Option": {
          "_figure": [
            null
          ]
        },
        "IIFL India Growth Fund -Regular Plan - Growth": {
          "_figure": [
            null
          ]
        },
        "SBI Magnum Multicap Fund - REGULAR PLAN -Growth Option": {
          "_figure": [
            10.1704693596904
          ]
        },
        "Kotak Select Focus Fund - Growth": {
          "_figure": [
            10.7785458258239
          ]
        },
        "HDFC Equity Fund - Growth Option": {
          "_figure": [
            8.29168295966879
          ]
        },
        "Franklin India Flexi Cap Fund-Growth Plan": {
          "_figure": [
            9.52777086776355
          ]
        },
        "_figure": [
          9.998290130663644
        ],
        "Franklin India High Growth Companies Fund - Growth Plan": {
          "_figure": [
            12.0111958711599
          ]
        },
        "Birla Sun Life Equity Fund - Growth - Regular Plan": {
          "_figure": [
            10.5597033707683
          ]
        },
        "ICICI Prudential Value Discovery Fund - Growth": {
          "_figure": [
            12.494420125849
          ]
        },
        "Axis Equity Fund - Growth": {
          "_figure": [
            8.30198971811754
          ]
        }
      },
      "Equity - FMCG": {
        "_figure": [
          12.9391809175777
        ],
        "SBI FMCG FUND - REGULAR - GROWTH": {
          "_figure": [
            null
          ]
        },
        "ICICI Prudential FMCG Fund - Growth": {
          "_figure": [
            12.9391809175777
          ]
        }
      },
      "Equity - Banking": {
        "_figure": [
          7.756301964533782
        ],
        "UTI Banking Sector Fund-Income Option": {
          "_figure": [
            4.48544488820235
          ]
        },
        "Kotak Banking ETF": {
          "_figure": [
            null
          ]
        },
        "Birla Sun Life Banking and Financial Services Fund - Regular Plan - Growth": {
          "_figure": [
            null
          ]
        },
        "R*Shares Bank BeES": {
          "_figure": [
            null
          ]
        },
        "Reliance Banking Fund-Growth Plan-Growth Option": {
          "_figure": [
            8.2686147173821
          ]
        },
        "SBI BANKING & FINANCIAL SERVICES FUND - REGULAR PLAN - GROWTH": {
          "_figure": [
            null
          ]
        },
        "ICICI Prudential Banking and Financial Services Fund -  Growth": {
          "_figure": [
            11.0147287026105
          ]
        },
        "UTI Banking Sector Fund-Growth Option": {
          "_figure": [
            7.25641954994018
          ]
        }
      },
      "Gold Fund": {
        "R*Shares Gold BeES": {
          "_figure": [
            null
          ]
        },
        "_figure": [
          4.0762242905284065
        ],
        "HDFC Gold Exchange Traded Fund": {
          "_figure": [
            6.03459415600124
          ]
        },
        "SBI GOLD EXCHANGE TRADED SCHEME": {
          "_figure": [
            6.14783904734468
          ]
        },
        "KOTAK GOLD ETF": {
          "_figure": [
            -3.40119263557552
          ]
        },
        "Kotak Gold Fund Growth": {
          "_figure": [
            5.61706623223513
          ]
        },
        "Axis Gold ETF": {
          "_figure": [
            5.9828146526365
          ]
        }
      }
      }
}

//console.log(rObj.values;);
//container
var values = rObj.values;
//Index
var find = "Equity - Pharma";
//subIndex
var subFind = "SBI PHARMA - REGULAR PLAN -GROWTH";
var case1 = values[find][subFind]["_figure"][0];
If you want to find the specific just change the variables the corresponding 
names [find] i.e "Equity - Pharma" then subFind i.e "SBI PHARMA - REGULAR 
PLAN -GROWTH"

for(var index in values) {
    if(index === find) {
        var nextIndex = values[index];
        for(var nextFind in nextIndex) {
            var Item = nextIndex[nextFind];
            if(nextFind === subFind) {
                  console.log(Item["_figure"][0]);
            }
        }
    }
}

【讨论】:

  • 非常感谢,邪恶的猪排博士。
  • :) 呜呜呜!~~
【解决方案2】:

Object.prototype.hasOwnProperty() 应该可以解决问题。这将为您提供迭代时的键和值。 例如:

var buz = {
  fog: 'stack'
};

for (var name in buz) {
  if (buz.hasOwnProperty(name)) {
    console.log('this is fog (' + 
      name + ') for sure. Value: ' + buz[name]);
  }
  else {
    console.log(name); // toString or something else
  }
}

文档链接:Object.prototype.hasOwnProperty()

【讨论】:

    【解决方案3】:

    使用它从对象中提取所有 _figure 作为数组。

    var figures=[];
    Object.keys(data.values).forEach(function(val){
     Object.keys(data.values[val]).forEach(function(_val){
        if(data.values[val][_val]&&data.values[val][_val]._figure){
           figures.push(data.values[val][_val]._figure[0]);
        }
      });
    })
    
    console.log(figures);
    

    SNIPPET-1

    var data = {
    "values" : {
          "EquityTechnology": {
            "_figure": [
              9.138790534659202
            ],
            "ICICIPrudentialTechnologyFundGrowth": {
              "_figure": [
                10.6484932862722
              ]
            },
            "Franklin Infotech Fund-Growth": {
              "_figure": [
                7.96902834459266
              ]
            },
            "Birla Sun Life New Millenium Fund - Growth - Regular Plan": {
              "_figure": [
                8.79884997311275
              ]
            },
            "SBI IT FUND - REGULAR PLAN - GROWTH": {
              "_figure": [
                null
              ]
            }
          },
          "Equity - SmallCap": {
            "_figure": [
              14.0064060591969
            ],
            "HDFC Small Cap Fund - Regular Growth Plan": {
              "_figure": [
                null
              ]
            },
            "Reliance Mid & Small Cap Fund -Growth Plan -Growth Option": {
              "_figure": [
                11.8481966627509
              ]
            },
            "Franklin India Smaller Companies Fund-Growth": {
              "_figure": [
                15.3302065566009
              ]
            },
            "Sundaram S.M.I.L.E.Fund-Growth": {
              "_figure": [
                11.754220292209
              ]
            },
            "SBI Magnum MIDCAP FUND - REGULAR PLAN - GROWTH": {
              "_figure": [
                14.9351631127958
              ]
            },
            "Birla Sun Life Small & Midcap Fund - GROWTH": {
              "_figure": [
                12.3666676648488
              ]
            },
            "L&T Emerging Businesses Fund - Regular Plan - Growth Option": {
              "_figure": [
                null
              ]
            },
            "Canara Robeco Emerging Equities - Regular Plan - GROWTH": {
              "_figure": [
                14.6579568171628
              ]
            },
            "Reliance Small Cap Fund - Growth Plan - Growth Option": {
              "_figure": [
                15.0019513606657
              ]
            },
            "DSP BlackRock Micro Cap Fund - Regular - Growth": {
              "_figure": [
                16.1568860065413
              ]
            }
          },
          "Equity - Pharma": {
            "_figure": [
              12.966782129169834
            ],
            "SBI PHARMA - REGULAR PLAN -GROWTH": {
              "_figure": [
                14.9918670876748
              ]
            },
            "UTI Pharma & Healthcare Fund-Growth Option": {
              "_figure": [
                11.2119667676491
              ]
            },
            "Reliance Pharma Fund-Growth Plan-Growth Option": {
              "_figure": [
                12.6965125321856
              ]
            }
          },
          "Equity - MultiCap": {
            "DSP BlackRock Equity Fund - Regular Plan - Growth": {
              "_figure": [
                8.32832307169916
              ]
            },
            "DSP BlackRock Opportunities Fund-Regular Plan - Growth": {
              "_figure": [
                9.72369143832476
              ]
            },
            "MOSt Focused Multicap 35-Regular Plan-Growth Option": {
              "_figure": [
                null
              ]
            },
            "Reliance Equity Opportunities  Fund-Growth Plan-Growth Option": {
              "_figure": [
                9.79339882843478
              ]
            },
            "L&T Equity Fund-Regular Plan-Growth Option": {
              "_figure": [
                null
              ]
            },
            "IIFL India Growth Fund -Regular Plan - Growth": {
              "_figure": [
                null
              ]
            },
            "SBI Magnum Multicap Fund - REGULAR PLAN -Growth Option": {
              "_figure": [
                10.1704693596904
              ]
            },
            "Kotak Select Focus Fund - Growth": {
              "_figure": [
                10.7785458258239
              ]
            },
            "HDFC Equity Fund - Growth Option": {
              "_figure": [
                8.29168295966879
              ]
            },
            "Franklin India Flexi Cap Fund-Growth Plan": {
              "_figure": [
                9.52777086776355
              ]
            },
            "_figure": [
              9.998290130663644
            ],
            "Franklin India High Growth Companies Fund - Growth Plan": {
              "_figure": [
                12.0111958711599
              ]
            },
            "Birla Sun Life Equity Fund - Growth - Regular Plan": {
              "_figure": [
                10.5597033707683
              ]
            },
            "ICICI Prudential Value Discovery Fund - Growth": {
              "_figure": [
                12.494420125849
              ]
            },
            "Axis Equity Fund - Growth": {
              "_figure": [
                8.30198971811754
              ]
            }
          },
          "Equity - FMCG": {
            "_figure": [
              12.9391809175777
            ],
            "SBI FMCG FUND - REGULAR - GROWTH": {
              "_figure": [
                null
              ]
            },
            "ICICI Prudential FMCG Fund - Growth": {
              "_figure": [
                12.9391809175777
              ]
            }
          },
          "Equity - Banking": {
            "_figure": [
              7.756301964533782
            ],
            "UTI Banking Sector Fund-Income Option": {
              "_figure": [
                4.48544488820235
              ]
            },
            "Kotak Banking ETF": {
              "_figure": [
                null
              ]
            },
            "Birla Sun Life Banking and Financial Services Fund - Regular Plan - Growth": {
              "_figure": [
                null
              ]
            },
            "R*Shares Bank BeES": {
              "_figure": [
                null
              ]
            },
            "Reliance Banking Fund-Growth Plan-Growth Option": {
              "_figure": [
                8.2686147173821
              ]
            },
            "SBI BANKING & FINANCIAL SERVICES FUND - REGULAR PLAN - GROWTH": {
              "_figure": [
                null
              ]
            },
            "ICICI Prudential Banking and Financial Services Fund -  Growth": {
              "_figure": [
                11.0147287026105
              ]
            },
            "UTI Banking Sector Fund-Growth Option": {
              "_figure": [
                7.25641954994018
              ]
            }
          },
          "Gold Fund": {
            "R*Shares Gold BeES": {
              "_figure": [
                null
              ]
            },
            "_figure": [
              4.0762242905284065
            ],
            "HDFC Gold Exchange Traded Fund": {
              "_figure": [
                6.03459415600124
              ]
            },
            "SBI GOLD EXCHANGE TRADED SCHEME": {
              "_figure": [
                6.14783904734468
              ]
            },
            "KOTAK GOLD ETF": {
              "_figure": [
                -3.40119263557552
              ]
            },
            "Kotak Gold Fund Growth": {
              "_figure": [
                5.61706623223513
              ]
            },
            "Axis Gold ETF": {
              "_figure": [
                5.9828146526365
              ]
            }
          }
          }
    };
    
    var figures=[];
    Object.keys(data.values).forEach(function(val){
     Object.keys(data.values[val]).forEach(function(_val){
        if(data.values[val][_val]&&data.values[val][_val]._figure){
           figures.push(data.values[val][_val]._figure[0]);
        }
      });
    })
    
    console.log(figures);

    或者你可以试试这个。

    JSON.stringify(data).match(/"_figure":\[[0-9.]+\]/g).map(function(val){
          return parseFloat(val.match(/[0-9.]+/g)[0])
    });
    

    SNIPPET-2

    var data = {
    "values" : {
          "EquityTechnology": {
            "_figure": [
              9.138790534659202
            ],
            "ICICIPrudentialTechnologyFundGrowth": {
              "_figure": [
                10.6484932862722
              ]
            },
            "Franklin Infotech Fund-Growth": {
              "_figure": [
                7.96902834459266
              ]
            },
            "Birla Sun Life New Millenium Fund - Growth - Regular Plan": {
              "_figure": [
                8.79884997311275
              ]
            },
            "SBI IT FUND - REGULAR PLAN - GROWTH": {
              "_figure": [
                null
              ]
            }
          },
          "Equity - SmallCap": {
            "_figure": [
              14.0064060591969
            ],
            "HDFC Small Cap Fund - Regular Growth Plan": {
              "_figure": [
                null
              ]
            },
            "Reliance Mid & Small Cap Fund -Growth Plan -Growth Option": {
              "_figure": [
                11.8481966627509
              ]
            },
            "Franklin India Smaller Companies Fund-Growth": {
              "_figure": [
                15.3302065566009
              ]
            },
            "Sundaram S.M.I.L.E.Fund-Growth": {
              "_figure": [
                11.754220292209
              ]
            },
            "SBI Magnum MIDCAP FUND - REGULAR PLAN - GROWTH": {
              "_figure": [
                14.9351631127958
              ]
            },
            "Birla Sun Life Small & Midcap Fund - GROWTH": {
              "_figure": [
                12.3666676648488
              ]
            },
            "L&T Emerging Businesses Fund - Regular Plan - Growth Option": {
              "_figure": [
                null
              ]
            },
            "Canara Robeco Emerging Equities - Regular Plan - GROWTH": {
              "_figure": [
                14.6579568171628
              ]
            },
            "Reliance Small Cap Fund - Growth Plan - Growth Option": {
              "_figure": [
                15.0019513606657
              ]
            },
            "DSP BlackRock Micro Cap Fund - Regular - Growth": {
              "_figure": [
                16.1568860065413
              ]
            }
          },
          "Equity - Pharma": {
            "_figure": [
              12.966782129169834
            ],
            "SBI PHARMA - REGULAR PLAN -GROWTH": {
              "_figure": [
                14.9918670876748
              ]
            },
            "UTI Pharma & Healthcare Fund-Growth Option": {
              "_figure": [
                11.2119667676491
              ]
            },
            "Reliance Pharma Fund-Growth Plan-Growth Option": {
              "_figure": [
                12.6965125321856
              ]
            }
          },
          "Equity - MultiCap": {
            "DSP BlackRock Equity Fund - Regular Plan - Growth": {
              "_figure": [
                8.32832307169916
              ]
            },
            "DSP BlackRock Opportunities Fund-Regular Plan - Growth": {
              "_figure": [
                9.72369143832476
              ]
            },
            "MOSt Focused Multicap 35-Regular Plan-Growth Option": {
              "_figure": [
                null
              ]
            },
            "Reliance Equity Opportunities  Fund-Growth Plan-Growth Option": {
              "_figure": [
                9.79339882843478
              ]
            },
            "L&T Equity Fund-Regular Plan-Growth Option": {
              "_figure": [
                null
              ]
            },
            "IIFL India Growth Fund -Regular Plan - Growth": {
              "_figure": [
                null
              ]
            },
            "SBI Magnum Multicap Fund - REGULAR PLAN -Growth Option": {
              "_figure": [
                10.1704693596904
              ]
            },
            "Kotak Select Focus Fund - Growth": {
              "_figure": [
                10.7785458258239
              ]
            },
            "HDFC Equity Fund - Growth Option": {
              "_figure": [
                8.29168295966879
              ]
            },
            "Franklin India Flexi Cap Fund-Growth Plan": {
              "_figure": [
                9.52777086776355
              ]
            },
            "_figure": [
              9.998290130663644
            ],
            "Franklin India High Growth Companies Fund - Growth Plan": {
              "_figure": [
                12.0111958711599
              ]
            },
            "Birla Sun Life Equity Fund - Growth - Regular Plan": {
              "_figure": [
                10.5597033707683
              ]
            },
            "ICICI Prudential Value Discovery Fund - Growth": {
              "_figure": [
                12.494420125849
              ]
            },
            "Axis Equity Fund - Growth": {
              "_figure": [
                8.30198971811754
              ]
            }
          },
          "Equity - FMCG": {
            "_figure": [
              12.9391809175777
            ],
            "SBI FMCG FUND - REGULAR - GROWTH": {
              "_figure": [
                null
              ]
            },
            "ICICI Prudential FMCG Fund - Growth": {
              "_figure": [
                12.9391809175777
              ]
            }
          },
          "Equity - Banking": {
            "_figure": [
              7.756301964533782
            ],
            "UTI Banking Sector Fund-Income Option": {
              "_figure": [
                4.48544488820235
              ]
            },
            "Kotak Banking ETF": {
              "_figure": [
                null
              ]
            },
            "Birla Sun Life Banking and Financial Services Fund - Regular Plan - Growth": {
              "_figure": [
                null
              ]
            },
            "R*Shares Bank BeES": {
              "_figure": [
                null
              ]
            },
            "Reliance Banking Fund-Growth Plan-Growth Option": {
              "_figure": [
                8.2686147173821
              ]
            },
            "SBI BANKING & FINANCIAL SERVICES FUND - REGULAR PLAN - GROWTH": {
              "_figure": [
                null
              ]
            },
            "ICICI Prudential Banking and Financial Services Fund -  Growth": {
              "_figure": [
                11.0147287026105
              ]
            },
            "UTI Banking Sector Fund-Growth Option": {
              "_figure": [
                7.25641954994018
              ]
            }
          },
          "Gold Fund": {
            "R*Shares Gold BeES": {
              "_figure": [
                null
              ]
            },
            "_figure": [
              4.0762242905284065
            ],
            "HDFC Gold Exchange Traded Fund": {
              "_figure": [
                6.03459415600124
              ]
            },
            "SBI GOLD EXCHANGE TRADED SCHEME": {
              "_figure": [
                6.14783904734468
              ]
            },
            "KOTAK GOLD ETF": {
              "_figure": [
                -3.40119263557552
              ]
            },
            "Kotak Gold Fund Growth": {
              "_figure": [
                5.61706623223513
              ]
            },
            "Axis Gold ETF": {
              "_figure": [
                5.9828146526365
              ]
            }
          }
          }
    };
    
    var figures = JSON.stringify(data).match(/"_figure":\[[0-9.]+\]/g).map(function(val){
          return parseFloat(val.match(/[0-9.]+/g)[0])
    });
    
    console.log(figures);

    【讨论】:

    • 非常感谢,纳迪尔。会试试这个。
    猜你喜欢
    • 1970-01-01
    • 2017-02-27
    • 1970-01-01
    • 2016-05-28
    • 1970-01-01
    • 1970-01-01
    • 2017-11-19
    • 2013-01-04
    • 1970-01-01
    相关资源
    最近更新 更多