-3
var data = [
    [{
        min: "3.00",
        max: "3.00",
        mom: "3.00",
        paramname: "HV_CAP_B",
        color: "#42426F"
    }, {
        min: "3.00",
        max: "3.00",
        mom: "3.00",
        paramname: "HV_CAP_B",
        color: "#42426F"
    }, {
        min: "3.00",
        max: "3.00",
        mom: "3.00",
        paramname: "HV_CAP_B",
        color: "#42426F"
    }]
]

Does anyone know how to get the index of min, max, mom?

7
  • what do you mean by "the index of"? aren't these three objects in an array, with the same values in every object in the array? Commented Sep 12, 2013 at 8:49
  • you have no "max" , just "mas" :p Commented Sep 12, 2013 at 8:49
  • Object properties are not indexed (they're actually not guaranteed to be ordered reliably across implementations). Commented Sep 12, 2013 at 8:49
  • 1
    Is there a reason why the json object contains nested arrays? Commented Sep 12, 2013 at 8:49
  • @KevinBowersox just saw that too. Commented Sep 12, 2013 at 8:50

3 Answers 3

0

I fear i don't understand the question. But if you want to read for example the first min value of your object, you can do this :

var min = data[0][0].min;

If you want the second min, it's this :

var min2 = data[0][1].min
Sign up to request clarification or add additional context in comments.

Comments

0

Use for loop and add them in an array

   var min = [],
       mas=[];
   for (var i = 0; i < data[0].length; i++) {
        console.log("min = " + data[0][i].min + " mas = "+ data[0][i].mas)
        min.push(data[0][i].min);
        mas.push(data[0][i].mas);
    }

/*Output

min = 3.00 mas = 3.00
min = 3.00 mas = 3.00
min = 3.00 mas = 3.00

*/

Comments

0

you will get value with data[0].min

Comments

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.