Link to home
Start Free TrialLog in
Avatar of Isaac
IsaacFlag for United States of America

asked on

Retrieve index value from JSON

How can I retrieve the index of a JSON array?  In my json, there's a PlanNumber with a value and I need to retrieve the index.  The Json in my fiddle show 5 contracts and each having a plan number.

Not working for me.
var index = -1;
var val = "8930-3o3pp";
var filteredObj = jsonFile.Result.Contracts.find(function(item, i){
  if(item.Plan.PlanNumber === val){
    index = i;
    return i;
  }
});

alert(index, filteredObj);

Open in new window

https://jsfiddle.net/isogunro/z6f33doy/3/
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Isaac

ASKER

Thanks.
I see what I did wrong.
Avatar of Isaac

ASKER

When I move it to my site, I get "object doesn't support property or method .find"
Avatar of Isaac

ASKER

That sucks, IE does not support .find()