0
我有一個來自URL的大JSON文件的API,我試圖做的是創建一個時間表。我已經儘可能地打印JSON文件的某些部分,但我似乎無法得到它的需求。這裏是JSON的樣本,這是一個值得健身課程只有兩天:將JSON數據轉換爲時間表
{
"error": 0,
"msg": "Calendar data available",
"data": [
{
"daylabel": "Saturday 1st of April 2017",
"datetime": 1490965200,
"classdata": [
{
"id": "22728",
"name": "TRX/Kettlebell",
"leadbyuserid": "1395",
"startdatetime": "1490985900",
"enddatetime": "1490988600",
"bookingtypeid": "88",
"maxcount": "14",
"shortname": "TRXK",
"isactive": "1",
"isbooked": "1",
"screentypeid": "2",
"trainername": "Gianluca Silvestrini",
"classlabel": "TRX/Kettlebell",
"displaylabel": "05:45am - 06:30am - Studio 2",
"trainerlabel": "Trainer: Gianluca Silvestrini",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21367",
"name": "Barre",
"leadbyuserid": "695",
"startdatetime": "1490988600",
"enddatetime": "1490991300",
"bookingtypeid": "6",
"maxcount": "26",
"shortname": "BARR",
"isactive": "1",
"isbooked": "1",
"screentypeid": "1",
"trainername": "Angelique Maslen",
"classlabel": "Barre",
"displaylabel": "06:30am - 07:15am - Studio 1",
"trainerlabel": "Trainer: Angelique Maslen",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21365",
"name": "Streamline Body Sculpting™ ",
"leadbyuserid": "1001",
"startdatetime": "1490990400",
"enddatetime": "1490993100",
"bookingtypeid": "95",
"maxcount": "18",
"shortname": "SBS",
"isactive": "1",
"isbooked": "1",
"screentypeid": "2",
"trainername": "Tim Heasman",
"classlabel": "Streamline Body Sculpting™ ",
"displaylabel": "07:00am - 07:45am - Studio 2",
"trainerlabel": "Trainer: Tim Heasman",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21366",
"name": "Small Group Circuit Training",
"leadbyuserid": "1395",
"startdatetime": "1490990400",
"enddatetime": "1490992800",
"bookingtypeid": "71",
"maxcount": "14",
"shortname": "SGCT",
"isactive": "1",
"isbooked": "1",
"screentypeid": "3",
"trainername": "Gianluca Silvestrini",
"classlabel": "Small Group Circuit Training",
"displaylabel": "07:00am - 07:40am - Main Floor",
"trainerlabel": "Trainer: Gianluca Silvestrini",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21364",
"name": "Aerial Foundations",
"leadbyuserid": "695",
"startdatetime": "1490992200",
"enddatetime": "1490994900",
"bookingtypeid": "108",
"maxcount": "18",
"shortname": "AFIT",
"isactive": "1",
"isbooked": "1",
"screentypeid": "1",
"trainername": "Angelique Maslen",
"classlabel": "Aerial Foundations",
"displaylabel": "07:30am - 08:15am - Studio 1",
"trainerlabel": "Trainer: Angelique Maslen",
"isfull": 1,
"styledata": "background-color:#666;color:#fff;"
},
{
"id": "21363",
"name": "Kettlebell Circuit ",
"leadbyuserid": "1001",
"startdatetime": "1490994000",
"enddatetime": "1490996400",
"bookingtypeid": "99",
"maxcount": "18",
"shortname": "KBL",
"isactive": "1",
"isbooked": "1",
"screentypeid": "3",
"trainername": "Tim Heasman",
"classlabel": "Kettlebell Circuit ",
"displaylabel": "08:00am - 08:40am - Main Floor",
"trainerlabel": "Trainer: Tim Heasman",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21362",
"name": "Mat Pilates",
"leadbyuserid": "1373",
"startdatetime": "1490994900",
"enddatetime": "1490997600",
"bookingtypeid": "89",
"maxcount": "18",
"shortname": "MATP",
"isactive": "1",
"isbooked": "1",
"screentypeid": "2",
"trainername": "Kylie Tabrett",
"classlabel": "Mat Pilates",
"displaylabel": "08:15am - 09:00am - Studio 2",
"trainerlabel": "Trainer: Kylie Tabrett",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21361",
"name": "TRX/Pilates",
"leadbyuserid": "16",
"startdatetime": "1490995800",
"enddatetime": "1490998500",
"bookingtypeid": "97",
"maxcount": "20",
"shortname": "TRXP",
"isactive": "1",
"isbooked": "1",
"screentypeid": "1",
"trainername": "John Rahme",
"classlabel": "TRX/Pilates",
"displaylabel": "08:30am - 09:15am - Studio 1",
"trainerlabel": "Trainer: John Rahme",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21360",
"name": "Small Group Cardio",
"leadbyuserid": "15",
"startdatetime": "1490997000",
"enddatetime": "1490999400",
"bookingtypeid": "100",
"maxcount": "14",
"shortname": "SMGC",
"isactive": "1",
"isbooked": "1",
"screentypeid": "3",
"trainername": "Lyndsay Flight",
"classlabel": "Small Group Cardio",
"displaylabel": "08:50am - 09:30am - Main Floor",
"trainerlabel": "Trainer: Lyndsay Flight",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "26080",
"name": "40 Day Focus Measurements",
"leadbyuserid": "16",
"startdatetime": "1490997600",
"enddatetime": "1491000900",
"bookingtypeid": "124",
"maxcount": "20",
"shortname": "MEAS",
"isactive": "1",
"isbooked": "1",
"screentypeid": "0",
"trainername": "John Rahme",
"classlabel": "40 Day Focus Measurements",
"displaylabel": "09:00am - 09:55am",
"trainerlabel": "Trainer: John Rahme",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21359",
"name": "Restorative Yoga",
"leadbyuserid": "1094",
"startdatetime": "1490998500",
"enddatetime": "1491002100",
"bookingtypeid": "84",
"maxcount": "20",
"shortname": "RSYO",
"isactive": "1",
"isbooked": "1",
"screentypeid": "2",
"trainername": "Jennifer Vo",
"classlabel": "Restorative Yoga",
"displaylabel": "09:15am - 10:15am - Studio 2",
"trainerlabel": "Trainer: Jennifer Vo",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21357",
"name": "Barre",
"leadbyuserid": "15",
"startdatetime": "1491000300",
"enddatetime": "1491003000",
"bookingtypeid": "6",
"maxcount": "26",
"shortname": "BARR",
"isactive": "1",
"isbooked": "1",
"screentypeid": "1",
"trainername": "Lyndsay Flight",
"classlabel": "Barre",
"displaylabel": "09:45am - 10:30am - Studio 1",
"trainerlabel": "Trainer: Lyndsay Flight",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21358",
"name": "Mat Pilates",
"leadbyuserid": "1373",
"startdatetime": "1491000300",
"enddatetime": "1491003000",
"bookingtypeid": "119",
"maxcount": "12",
"shortname": "MATP",
"isactive": "1",
"isbooked": "1",
"screentypeid": "3",
"trainername": "Kylie Tabrett",
"classlabel": "Mat Pilates",
"displaylabel": "09:45am - 10:30am - Main Floor",
"trainerlabel": "Trainer: Kylie Tabrett",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21356",
"name": "TRX/Pilates Studio 2",
"leadbyuserid": "1395",
"startdatetime": "1491003000",
"enddatetime": "1491005700",
"bookingtypeid": "98",
"maxcount": "14",
"shortname": "TRXP",
"isactive": "1",
"isbooked": "1",
"screentypeid": "2",
"trainername": "Gianluca Silvestrini",
"classlabel": "TRX/Pilates Studio 2",
"displaylabel": "10:30am - 11:15am - Studio 2",
"trainerlabel": "Trainer: Gianluca Silvestrini",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21354",
"name": "Streamline Body Sculpting™",
"leadbyuserid": "1001",
"startdatetime": "1491003900",
"enddatetime": "1491006600",
"bookingtypeid": "68",
"maxcount": "28",
"shortname": "SBS",
"isactive": "1",
"isbooked": "1",
"screentypeid": "3",
"trainername": "Tim Heasman",
"classlabel": "Streamline Body Sculpting™",
"displaylabel": "10:45am - 11:30am - Main Floor",
"trainerlabel": "Trainer: Tim Heasman",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "27553",
"name": "Detox Launch Seminar",
"leadbyuserid": "16",
"startdatetime": "1491004800",
"enddatetime": "1491008100",
"bookingtypeid": "127",
"maxcount": "50",
"shortname": "DTOX",
"isactive": "1",
"isbooked": "1",
"screentypeid": "1",
"trainername": "John Rahme",
"classlabel": "Detox Launch Seminar",
"displaylabel": "11:00am - 11:55am - Studio 1",
"trainerlabel": "Trainer: John Rahme",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "24513",
"name": "Gentle Flow Yoga",
"leadbyuserid": "921",
"startdatetime": "1491006600",
"enddatetime": "1491010200",
"bookingtypeid": "92",
"maxcount": "20",
"shortname": "GFYO",
"isactive": "1",
"isbooked": "1",
"screentypeid": "2",
"trainername": "Denise Sorrell",
"classlabel": "Gentle Flow Yoga",
"displaylabel": "11:30am - 12:30pm - Studio 2",
"trainerlabel": "Trainer: Denise Sorrell",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
}
]
},
{
"daylabel": "Sunday 2nd of April 2017",
"datetime": 1491051600,
"classdata": [
{
"id": "21352",
"name": "Barre",
"leadbyuserid": "885",
"startdatetime": "1491080400",
"enddatetime": "1491083100",
"bookingtypeid": "6",
"maxcount": "26",
"shortname": "BARR",
"isactive": "1",
"isbooked": "1",
"screentypeid": "1",
"trainername": "Anna McLeod",
"classlabel": "Barre",
"displaylabel": "07:00am - 07:45am - Studio 1",
"trainerlabel": "Trainer: Anna McLeod",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21351",
"name": "Flow Yoga",
"leadbyuserid": "921",
"startdatetime": "1491081300",
"enddatetime": "1491084900",
"bookingtypeid": "81",
"maxcount": "20",
"shortname": "FYO",
"isactive": "1",
"isbooked": "1",
"screentypeid": "2",
"trainername": "Denise Sorrell",
"classlabel": "Flow Yoga",
"displaylabel": "07:15am - 08:15am - Studio 2",
"trainerlabel": "Trainer: Denise Sorrell",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21350",
"name": "Streamline Body Sculpting™",
"leadbyuserid": "1342",
"startdatetime": "1491084000",
"enddatetime": "1491086700",
"bookingtypeid": "68",
"maxcount": "28",
"shortname": "SBS",
"isactive": "1",
"isbooked": "1",
"screentypeid": "1",
"trainername": "Rebecca Pearsall",
"classlabel": "Streamline Body Sculpting™",
"displaylabel": "08:00am - 08:45am - Studio 1",
"trainerlabel": "Trainer: Rebecca Pearsall",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21349",
"name": "Mat Pilates",
"leadbyuserid": "885",
"startdatetime": "1491084000",
"enddatetime": "1491086700",
"bookingtypeid": "119",
"maxcount": "12",
"shortname": "MATP",
"isactive": "1",
"isbooked": "1",
"screentypeid": "3",
"trainername": "Anna McLeod",
"classlabel": "Mat Pilates",
"displaylabel": "08:00am - 08:45am - Main Floor",
"trainerlabel": "Trainer: Anna McLeod",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21348",
"name": "Restorative Yoga",
"leadbyuserid": "921",
"startdatetime": "1491085800",
"enddatetime": "1491089400",
"bookingtypeid": "84",
"maxcount": "20",
"shortname": "RSYO",
"isactive": "1",
"isbooked": "1",
"screentypeid": "2",
"trainername": "Denise Sorrell",
"classlabel": "Restorative Yoga",
"displaylabel": "08:30am - 09:30am - Studio 2",
"trainerlabel": "Trainer: Denise Sorrell",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21347",
"name": "Small Group Circuit Training",
"leadbyuserid": "1342",
"startdatetime": "1491087600",
"enddatetime": "1491090000",
"bookingtypeid": "71",
"maxcount": "14",
"shortname": "SGCT",
"isactive": "1",
"isbooked": "1",
"screentypeid": "3",
"trainername": "Rebecca Pearsall",
"classlabel": "Small Group Circuit Training",
"displaylabel": "09:00am - 09:40am - Main Floor",
"trainerlabel": "Trainer: Rebecca Pearsall",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21346",
"name": "Barre",
"leadbyuserid": "885",
"startdatetime": "1491087600",
"enddatetime": "1491090300",
"bookingtypeid": "6",
"maxcount": "26",
"shortname": "BARR",
"isactive": "1",
"isbooked": "1",
"screentypeid": "1",
"trainername": "Anna McLeod",
"classlabel": "Barre",
"displaylabel": "09:00am - 09:45am - Studio 1",
"trainerlabel": "Trainer: Anna McLeod",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21345",
"name": "Aerial Pilates ",
"leadbyuserid": "1036",
"startdatetime": "1491090600",
"enddatetime": "1491093000",
"bookingtypeid": "101",
"maxcount": "11",
"shortname": "APIL",
"isactive": "1",
"isbooked": "1",
"screentypeid": "2",
"trainername": "Tanya Watts",
"classlabel": "Aerial Pilates ",
"displaylabel": "09:50am - 10:30am - Studio 2",
"trainerlabel": "Trainer: Tanya Watts",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21344",
"name": "Semi-Private Kettlebell Circuit",
"leadbyuserid": "1342",
"startdatetime": "1491091200",
"enddatetime": "1491093600",
"bookingtypeid": "96",
"maxcount": "14",
"shortname": "SEMK",
"isactive": "1",
"isbooked": "1",
"screentypeid": "3",
"trainername": "Rebecca Pearsall",
"classlabel": "Semi-Private Kettlebell Circuit",
"displaylabel": "10:00am - 10:40am - Main Floor",
"trainerlabel": "Trainer: Rebecca Pearsall",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21343",
"name": "Mat Pilates ",
"leadbyuserid": "885",
"startdatetime": "1491091200",
"enddatetime": "1491093900",
"bookingtypeid": "2",
"maxcount": "36",
"shortname": "MATP",
"isactive": "1",
"isbooked": "1",
"screentypeid": "1",
"trainername": "Anna McLeod",
"classlabel": "Mat Pilates ",
"displaylabel": "10:00am - 10:45am - Studio 1",
"trainerlabel": "Trainer: Anna McLeod",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
},
{
"id": "21342",
"name": "Aerial Yoga",
"leadbyuserid": "1036",
"startdatetime": "1491093900",
"enddatetime": "1491096900",
"bookingtypeid": "90",
"maxcount": "11",
"shortname": "AYO",
"isactive": "1",
"isbooked": "1",
"screentypeid": "2",
"trainername": "Tanya Watts",
"classlabel": "Aerial Yoga",
"displaylabel": "10:45am - 11:35am - Studio 2",
"trainerlabel": "Trainer: Tanya Watts",
"isfull": 1,
"styledata": "background-color:#666;color:#fff;"
},
{
"id": "21341",
"name": "Small Group Circuit Training",
"leadbyuserid": "1342",
"startdatetime": "1491094800",
"enddatetime": "1491097200",
"bookingtypeid": "71",
"maxcount": "14",
"shortname": "SGCT",
"isactive": "1",
"isbooked": "1",
"screentypeid": "3",
"trainername": "Rebecca Pearsall",
"classlabel": "Small Group Circuit Training",
"displaylabel": "11:00am - 11:40am - Main Floor",
"trainerlabel": "Trainer: Rebecca Pearsall",
"isfull": 0,
"styledata": "background-color:#008c8c;color:#fff;"
}
]
}
]
}
我需要它,因此dayLabel對象變得與它下面的所有類一欄,只像這樣:http://quanticalabs.com/script/timetable-responsive-schedule-for-wordpress/7010836
任何獲得訪問嵌套對象和創建正確的循環,並以這種方式吐出他們的幫助將是偉大的,先謝謝你。