Is my JSON correct?
I've implemented a JSON and an RSS feed into FullCalendar [only currently pulling events from开发者_Go百科 JSON]. Using CodeIgniter I've created my JSON using the following code
<?php
$jsonevents = array();
foreach($events->result() as $entry){
$jsonevents[] = array(
'id' => $entry->eventID,
'title' => $entry->eventTitle,
'start' => $entry->startDate,
'end' => $entry->endDate,
'allDay' => false
);
}
echo json_encode($jsonevents);
?>
The following outputs this JSON
[{"id":"1234567891","title":"Test 3","start":"2011-05-07 00:00:00","end":"2011-05-13 00:00:00","allDay":false},
{"id":"24242","title":"sdfsdfsdfsdf","start":"2011-05-05 13:00:53","end":"2011-05-06 17:00:19","allDay":false},
{"id":"1234567890","title":"Test","start":"2011-05-05 13:00:53","end":"2011-05-06 17:00:19","allDay":false}]
The issue is when imported into FullCalendar it creates an event within an event, I believe it might have something to do with the square brackets, but I'm unsure of how to correct the output, anyone have any ideas?
Your json is right.
I've validated it with http://json.bloople.net/
You may have another problem when applying it to your calendar plugin.
I've just formatted your json string with JSON Formatter & Validator and it's valid.
The square brackets mean that the whole thing is an array. Please refer to json.org.
Json is right.. yay.
I also had this problem ;)
Make all day True and look below on the time.
2011-05-07 00:00:00
try notice the 'T'
2011-05-07T00:00:00
Here is a sample of my complex feed
[{"title":"Tee Times","start":"2011-05-03T00:00:00","end":"2011-05-03T00:00:00","allDay":true,"color":"rgb(21,144,51)","groupsize":"","className":"data-brs clickable","cache":null,"EventName":null,"description":null,"EventCompTypeMSP":null,"url":null,"CompName":null,"CompCourseName":null,"CompNumberDivs":null,"CompQualifierYN":null,"CompNumber":null},{"title":"Tee Times","start":"2011-05-04T00:00:00","end":"2011-05-04T00:00:00","allDay":true,"color":"rgb(21,144,51)","groupsize":"","className":"data-brs clickable","cache":null,"EventName":null,"description":null,"EventCompTypeMSP":null,"url":null,"CompName":null,"CompCourseName":null,"CompNumberDivs":null,"CompQualifierYN":null,"CompNumber":null},{"title":"Tee Times","start":"2011-05-05T00:00:00","end":"2011-05-05T00:00:00","allDay":true,"color":"rgb(21,144,51)","groupsize":"","className":"data-brs clickable","cache":null,"EventName":null,"description":null,"EventCompTypeMSP":null,"url":null,"CompName":null,"CompCourseName":null,"CompNumberDivs":null,"CompQualifierYN":null,"CompNumber":null},{"title":"Tee Times","start":"2011-05-06T00:00:00","end":"2011-05-06T00:00:00","allDay":true,"color":"rgb(21,144,51)","groupsize":"","className":"data-brs clickable","cache":null,"EventName":null,"description":null,"EventCompTypeMSP":null,"url":null,"CompName":null,"CompCourseName":null,"CompNumberDivs":null,"CompQualifierYN":null,"CompNumber":null},{"title":"","start":"2011-05-03T07:10:00","end":"2011-05-03T08:00:00","allDay":false,"color":"rgb(21,144,51)","groupsize":"","className":"data-brs clickable","cache":null,"EventName":null,"description":null,"EventCompTypeMSP":null,"url":null,"CompName":null,"CompCourseName":null,"CompNumberDivs":null,"CompQualifierYN":null,"CompNumber":null},{"title":"Test","start":"2011-05-04T07:00:00","end":"2011-05-04T07:50:00","allDay":false,"color":"rgb(21,144,51)","groupsize":"","className":"data-brs clickable","cache":null,"EventName":null,"description":null,"EventCompTypeMSP":null,"url":null,"CompName":null,"CompCourseName":null,"CompNumberDivs":null,"CompQualifierYN":null,"CompNumber":null},{"title":"Riley","start":"2011-05-04T08:00:00","end":"2011-05-04T08:00:00","allDay":false,"color":"rgb(21,144,51)","groupsize":"4","className":"data-brs clickable","cache":null,"EventName":null,"description":null,"EventCompTypeMSP":null,"url":null,"CompName":null,"CompCourseName":null,"CompNumberDivs":null,"CompQualifierYN":null,"CompNumber":null},{"title":"Test","start":"2011-05-04T08:10:00","end":"2011-05-04T17:50:00","allDay":false,"color":"rgb(21,144,51)","groupsize":"","className":"data-brs clickable","cache":null,"EventName":null,"description":null,"EventCompTypeMSP":null,"url":null,"CompName":null,"CompCourseName":null,"CompNumberDivs":null,"CompQualifierYN":null,"CompNumber":null},{"title":"pea","start":"2011-05-05T08:10:00","end":"2011-05-05T08:10:00","allDay":false,"color":"rgb(21,144,51)","groupsize":"1","className":"data-brs clickable","cache":null,"EventName":null,"description":null,"EventCompTypeMSP":null,"url":null,"CompName":null,"CompCourseName":null,"CompNumberDivs":null,"CompQualifierYN":null,"CompNumber":null},{"title":"peter","start":"2011-05-06T07:10:00","end":"2011-05-06T07:10:00","allDay":false,"color":"rgb(21,144,51)","groupsize":"1","className":"data-brs clickable","cache":null,"EventName":null,"description":null,"EventCompTypeMSP":null,"url":null,"CompName":null,"CompCourseName":null,"CompNumberDivs":null,"CompQualifierYN":null,"CompNumber":null},{"title":"March Medal - Mens Medal - CSS: 70 - PAR: 70 - Click for more info...","start":"2011-03-15T00:00:00","end":null,"allDay":null,"color":"rgb(10,87,164)","groupsize":null,"className":"data-previous clickable","cache":null,"EventName":null,"description":null,"EventCompTypeMSP":null,"url":"http://www.howdidido.co.uk/ClubDetails.aspx?section=24&pagesection=compresultsdetails&compid=383","CompName":"March Medal","CompCourseName":"White Tee's","CompNumberDivs":1,"CompQualifierYN":"N","CompNumber":383}]
精彩评论