views:

269

answers:

1

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": {
            "name": "session"
        }
    }
]
+1  A: 

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.

jeffamaphone