开发者

What's wrong with my JSON feed?

I am trying setting up the Fullcalendar JQuery plugin with a JSON feed. It is not working, so I tried with the provided example with the plugin, and it works with that, so it is clearly a problem with my feed.

Here is the output of the example JSON feed (which works):

http://pastebin.com/wFGdhEqu

And here, the output of my JSON feed, which is not working:

http://pastebin.com/UyN4c6yc

Can anyone see anything wrong with the syntax?

The output worked when I printed it inside the .js config with PHP (well, I only changed one things after it wouldnt work: i put quotes on the property names), so I think the data i开发者_如何转开发s good...

EDIT: fixed second link


Run your invalid JSON through a validator like JSONLint. It might be quicker than asking people to hand-validate your output.

Updated:

It is easier to work with small sets of data at first than large. You have a couple of problems with your JSON:

  • Use double quotes, not single quotes
  • Use a date rather than new Date('xx-xx-xxxx')

Here is a sample of valid JSON using your data:

[
    {
        "title": "1",
        "start": "2011-01-01",
        "className": "ottype1"
    },
    {
        "title": "2",
        "start": "2011-01-02",
        "className": "ottype1"
    }
]

If you are creating your JSON by hand (which appears to be the case"), find a library to create your JSON for you.


This is your JSON

, 'start': new Date ('2011-01-01'),

this is the example JSON

,"start":"2011-06-10",

The date formatting is very very very very very very very... buggy.But- the newest version is supposed to be more relaxed.

This is a quote directly from the Documentation.

http://arshaw.com/fullcalendar/docs/event_data/Event_Object/

start Date. Required.

The date/time an event begins.

When specifying Event Objects for events or eventSources, you may specify a string in IETF format (ex: "Wed, 18 Oct 2009 13:00:00 EST"), a string in ISO8601 format (ex: "2009-11-05T13:15:30Z") or a UNIX timestamp.

Notice the 'T' in the time not all serialzers put this 'T' in - so be carefull for that too. And the 'Z' is 'no-time-zoning'; but this can be a pain for people from other countries.. again- also buggy.

And here is a very complex JSON from my site the beggining..

[{"title":"Tee Times","start":"2011-06-30T00:00:00","end":"2011-06-30T00:00:00","allDay":true,"color":"rgb(21,144,51)","groupsize":"","className":"data-brs clickable","cache":null,"EventName":null,"description":null,"EventCompTypeMSP":null,"url":null,"ID":null,"ID2":null,"CompName":null,"CompCourseName":null,"CompNumberDivs":null,"CompQualifierYN":null,"CompNumber":null},{"title":"Test","start":"2011

.. carries on for pages and end

ompetitions.aspx?compID=1088909","ID":40,"ID2":1088909,"CompName":"March Medal","CompCourseName":"Red Tee's","CompNumberDivs":1,"CompQualifierYN":"Y","CompNumber":40}]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜