I wanna develop web site which read some data from air time api.
it generate something like following:
({"env":"production","schedulerTime":"2012-07-11 14:44:34","previous":{"name":"Written By: Jalale Ale Ahmad - Modire Madrese [www.audiolib.ir]","starts":"2012-07-11 09:30:48.228571","ends":"2012-07-11 10:01:00.087571","type":"track"},"current":{"name":"Written By: Jalale Ale Ahmad - Modire Madrese [www.audiolib.ir]","starts":"2012-07-11 10:01:00.087571","ends":"2012-07-11 10:31:11.217571","media_item_played":true,"record":0,"type":"track"},"next":{"name":"Written By: Jalale Ale Ahmad - Modire Madrese [www.audiolib.ir]","starts":"2012-07-11 10:31:11.217571","ends":"2012-07-11 11:01:17.567071","type":"track"},"currentShow":[{"start_timestamp":"2012-07-11 13:58:00","end_timestamp":"2012-07-11 16:00:00","name":"Untitled Show","id":36,"instance_id":36,"record":0,"url":"","starts":"2012-07-11 13:58:00","ends":"2012-07-11 16:00:00"}],"nextShow":[],"timezone":"IRDT","timezoneOffset":"16200","AIRTIME_API_VERSION":"1.0"})
it's not JSON ,so what is that? and How should I convert it to php or javascript array?
it seems to be json(just get rid of the first round bracket).
you can use the below free on line tool to validate it
it seems to be valid JSON..check it in http://jsonlint.com/...
You can convert it to array using json_decode($output, true);
It's definitely JSON. You just have to skip the round brackets at the beginning and end of the data. The json_decode PHP function should be able to decode it for you then.
While it is not valid JSON, it looks like JSON with extra parenthesis around it. As Felix mentioned, could be a JSON-P-packaged response without function name. Either check API documentation on how to supply it or, if you can post-process data after receiving and before passing to JSON.parse, just remove ()
manually.