How to get the values from JSON in javascript following is my code
var obj={"0.5":0.009333, "0.21":0.048667,"0.31":0.070667};
var value =0.21;
var p=0;
for(i=0; i<= obj.length ;i++){
if(value== obj[i]){
p = obj[i]; //here i want p=0.048667
console.log("psr is :"+p);
}
}
obj.length is not supported in Javascript. You will have to loop over it using
But of course if you already know your key, then
is the way to go. The complete code becomes