0

I'm pretty new to coding and currently, I'm coding a React native project. 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.

{
"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. 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'. I want to retrieve '_figure' of all the items. I have tried for..in loop but it returned only the indexes of nested objects. Is there any way I can navigate through the JSON file using indexes?

Thank you in advance.

Sorry for the bad english.

9
  • why are you using object in the first place then use array for that purpose? Commented Jun 1, 2017 at 6:21
  • Do you want to access all figures? Commented Jun 1, 2017 at 6:23
  • hi Nadir, I want to access all the figures. The JSON data was given to me in this structure. Commented Jun 1, 2017 at 6:47
  • Is it okay if all the figures are retuned in an array? Commented Jun 1, 2017 at 6:48
  • yeah, no problem, Nadir. Commented Jun 1, 2017 at 6:49

3 Answers 3

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]);
            }
        }
    }
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot, Evil Dr. PorkChop.
:) oink oink!~~
0

Object.prototype.hasOwnProperty() should do the trick. 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()

Comments

0

Use this to extract all the _figure from object as array.

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);

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

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);

1 Comment

Thanks a lot, Nadir. will try this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.