我的 JSON 正确吗?
我已经在 FullCalendar 中实现了 JSON 和 RSS feed [目前仅从 JSON 中提取事件]。使用 CodeIgniter 我使用以下代码创建了 JSON
<?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);
?>
以下输出此 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}]
问题是当导入 FullCalendar 时,它会在事件中创建一个事件,我相信它可能与方括号有关,但我不确定如何纠正输出,有人有什么想法吗?
I've implemented a JSON and an RSS feed into FullCalendar [only currently pulling events from 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你的json是对的。
我已经用 http://json.bloople.net/ 验证了它,
您在应用它时可能会遇到另一个问题到您的日历插件。
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.
我刚刚使用 JSON Formatter & 格式化了你的 json 字符串。验证器并且它是有效的。
方括号意味着整个事物是一个数组。请参阅 json.org。
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.
杰森是对的..耶。
我也遇到了这个问题;)
将整天设置为 True,然后查看下面的时间。
尝试注意“T”
这是我的复杂提要的示例
Json is right.. yay.
I also had this problem ;)
Make all day True and look below on the time.
try notice the 'T'
Here is a sample of my complex feed