I've spent the last two days struggling with this error:

We've been utilizing REST-ful JSON server for a couple of months now to host
our data api (it's written using Zend Framework). Our client apps access
this API, and decode the JSON. Yesterday, one of our client apps stopped
working, generating no errors, no ouput, just a blank screen. After
commenting out the majority of the code, we found the following code was
causing the grief:

<?php

// BaseController extends Zend_Controller_Action
class CustomController extends BaseController {

  public function someAction() {

    $result = $this->api->get('resource', array('field1' => 'value1'));

    $result = Zend_Json::decode($result->getResponse()->getBody());

    var_dump($result);

    // exit;
  }

}

Now, we only get the blank screen when we allow our dispatcher to render our
Zend_Layout, Zend_View AFTER using Zend_Json::decode, all the following
logic steps work fine:

- Uncomment exit, prevent Layout, View rendering
var_dump($result);
exit;

- Check body for valid JSON (everything OK in JSON Lint)
- Layout, View render correctly
var_dump($result->getResponse()->getBody());

- Try another JSON string
- Layout, View render correctly
var_dump(Zend_Json::decode('[{"foo":"bar"}]'));

The JSON looks something like this:

[
    {
        "cm_broadcast_type": "National Broadcast Networks",
        "id": "12659575",
        "station_id": "12336",
        "program_id": "EP010501290006",
        "start_time": "20080814000000",
        "end_time": "20080814010000",
        "cc": "Y",
        "title": "Greatest American Dog"
    },
    {
        "cm_broadcast_type": "National Broadcast Networks",
        "id": "11469048",
        "station_id": "12336",
        "program_id": "EP007537910036",
        "start_time": "20080814010000",
        "end_time": "20080814020000",
        "cc": "Y",
        "title": "Criminal Minds"
    },
    ... Continue ...
]

So, as I've said, the problem only occurs when we allow the dispatcher to
continue rendering Layout, View after using Zend_Json::decode, any help
would be MUCH appreciated.

- jake

Reply via email to