I have this jquery code extracts gets the josn from url and put in html table
$(document).ready(function() {
$.getJSON('/api/students/2/?format=json', function(data) {
var items = [];
$.each(data, function(key, val) {
items.push('<tr><td>' +key+'</td><td>' + val + '</td></tr>');
});
$(items.join('')).appendTo('table');
});
});
This loads the first level of objects fine but i have many nested levels.
I have all the data inside json. currently it shows object[] but i want to shows its sub elements like below
like
studnets have semester then subjects and then assignments
i want to display them nested inside the main table within own tables like this
<table>
<tr><td>student name </td></tr>
<tr><td>semesters
<table>
<tr><td> subjects
<table><tr><td> Assigments
so that i can get the detail view of whole data in one page.
This looks like buggy but i am not able to find better way of represeting student data
EDIT
sample json data
{
"id": 2,
"name": "John",
"terms": [
{
"id": 26,
"name":"summer"
"date": "2013-02-18",
"subjects_set": [
{
"id": 10,
"name": "math",
"gb_type": [ ],
"assignment_set": [
{
"id": 2,
"name": "assignment_level_1",
"documents": [ ]
}
]
jsondata structure?