I know that I can retrieve "session" by using item.fields.name but what if I don't know in advance that the attribute is called "name". How can I retrieve the list of the attributes names in fields first.
[
{
"pk": 2,
"model": "auth.group",
"fields": {
开发者_JAVA技巧 "name": "session"
}
}
]
You can convert it to a javascript object, then iterate over the properties:
eval("var object = " + that_json_thing);
for (property in object) {
alert(property);
}
There is probably a "more correct" way of doing it, but this demonstrates the basic idea.
精彩评论