tags:

views:

11

answers:

0

So I've spent the past few weeks developing a proof of concept with JSON data. I've been loading the data into tables by building the blank table in HTML and inserting the JSON values data with jQuery's getJSON function like so:

 $('table#table_fourth_row tr:last td:first').html(data.tableDataCandyStuff.dataYearToDate.timePeriod);
$('table#table_fourth_row tr:last td:nth-child(2)').html(data.tableDataCandyStuff.dataYearToDate.TeddyBears);

Admittedly, this isn't the best way to go making tables, and I would prefer to refactor so that I may build the table from my JSON data which looks something like....

{
    "tableDataCandyStuff": {
        "label": "Candy Stuff",
        "dataDaily": {
            "timePeriod": "Daily",
            "TeddyBears": "7.14%",
            "Cinnamon": "$3,908,376",
            "Lollipops": "31.96%",
            "Butterflies": "$89,187",
            "CandyCanes": "$73,527",
            "Castles": "$5,882" 
        },
        "dataMonthToDate": {
            "timePeriod": "Month-to-date",
            "TeddyBears": "6.99%",
            "Cinnamon": "$59,139,972",
            "Lollipops": "32.08%",
            "Butterflies": "$1,326,150",
            "CandyCanes": "$1,064,823",
            "Castles": "$85,186" 
        },
        "dataYearToDate": {
            "timePeriod": "Year-to-date",
            "TeddyBears": "7.04%",
            "Cinnamon": "$242,901,763",
            "Lollipops": "32.14%",
            "Butterflies": "$5,496,031",
            "CandyCanes": "$4,386,294",
            "Castles": "$350,904" 
        } 
    }
}

I'm actually, not sure if the JSON is written in a structure that can be looped through to create a table from either.

Can anyone point me to a resource, whether it's a tut or a book or whatever that goes through practical applications of creating a JSON data structure and building a table from it? I looked at jqGrid and I couldn't make heads or tails of what my JSON structure needed to be like to use it.