[英]How to navigate through the nested JSON file using index in javascript?
I'm pretty new to coding and currently, I'm coding a React native project. 我是编码新手,目前正在编码React本机项目。 Sorry, if the question is too simple. 抱歉,如果问题太简单了。 I have tried many ways to navigate but failed. 我尝试了多种导航方式,但是失败了。 I have a JSON file and the data are as below. 我有一个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
]
}
}
}
}
I want to navigate through the JSON using the index as the data will be dynamic and the names could change over time. 我想使用索引浏览JSON,因为数据将是动态的,名称可能会随时间变化。 What should I do to access, for example, '14.9918670876748' under '_figure' of 'SBI PHARMA - REGULAR PLAN -GROWTH' which in turn is under 'Equity - Pharma'. 我应该怎么做,例如访问“ SBI PHARMA-REGULAR PLAN -GROWTH”的“ _figure”下的“ 14.9918670876748”,而该文件又位于“ Equity-Pharma”下。 I want to retrieve '_figure' of all the items. 我想检索所有项目的“ _figure”。 I have tried for..in loop but it returned only the indexes of nested objects. 我曾尝试for..in循环,但它仅返回嵌套对象的索引。 Is there any way I can navigate through the JSON file using indexes? 有什么方法可以使用索引浏览JSON文件吗?
Thank you in advance. 先感谢您。
Sorry for the bad english. 对不起,英语不好。
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]);
}
}
}
}
Object.prototype.hasOwnProperty()
should do the trick. Object.prototype.hasOwnProperty()
应该可以解决问题。 This will get you the key as well as the value while iterating. 这将在迭代时为您提供密钥和值。 For example: 例如:
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
}
}
Documentation link: Object.prototype.hasOwnProperty() 文档链接: Object.prototype.hasOwnProperty()
Use this to extract all the _figure from object as array. 使用它从对象中提取所有_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 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 SMILEFund-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);
or you can try this. 或者您可以尝试一下。
JSON.stringify(data).match(/"_figure":\[[0-9.]+\]/g).map(function(val){
return parseFloat(val.match(/[0-9.]+/g)[0])
});
SNIPPET-2 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 SMILEFund-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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.