After receiving JSON how can i create the row to show in Django view
Suppose i received the JSON object in my jquery function
[{"pk": 38, "model": "app.book", "fields": {"book_name": "Learn JSON", "book_branch": "Web"}}]
Now i want to know that how can 开发者_JAVA技巧i create the table row which i can append in the existing Table. provded that i don't know the fields in object.
Because I have to use same function on many objects which have different fields so i don't want to hard code the fields. I would like to get the field name automatically from JSON.
I have many examples from internet but they hardcode the fields
I assume you already parsed the JSON using jQuery.
You can simply use a for...in
[docs] loop to iterate over all properties of the object.
精彩评论