0

I am trying to figure out how to retrieve the values of a json of which i do not know the number of elements. Example:

my json can be something like

var json = ["fixelement1":"value1","fixelement2":"value2","fixelement3":"value3","variableelement4":"value4","variableelement5":"value5"]

or

var json =["fixelement1":"value1","fixelement2":"value2","fixelement3":"value3","variableelement7":"value7","variableelement8":"value8", "variableelementN":"valueN"]

the only thing that I know is that the first 3 elements are always the same. I use .indexOf() to search a value in fixelement3. What I would like to do is, if I find the element, I would like to retrieve the name of all the following elements (which number is variable and that are unknown) and their values.

javascript or jquery would work for me, but I have no idea.. thank you in advance!

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
Ob On Ken
  • 37
  • 1
  • 1
  • 8

1 Answers1

0
var json ={
   "fixelement1":"value1",
   "fixelement2":"value2",
   "fixelement3":"value3",
   "variableelement7":"value7",
   "variableelement8":"value8", 
   "variableelementN":"valueN"
}

for(prop in json){
    console.log('key ======> value', prop, '=====>', json[prop]);
}
Aravinder
  • 503
  • 4
  • 8
  • despite my poor explanation (I am nothing but a beginner) and my mistakes you 've got the point! thanks a million Aravinder! – Ob On Ken Dec 30 '16 at 06:31