I have an ajax request that returns the following.
{
"field1":{"label1":"message1"},
"field2":{"lable1":"message1"}
}
How can I reaad the values of “field1” and message1? The problem is that I don’t know the names of these labels, so right now they’re label1, label2, but it varies.
I’m trying this, but it gives me an object.
for (oneline in response) {
alert(response[oneline]);
}
I assume you already parsed the JSON, as you say you get an object. You can access it then like a normal JavaScript object:
Edit: Updated as the fields of the objects are unknown too.
onelinewill have the valuesfield1andfield2.