BaseController::returnJson & devMode interference While developing an API for a client site I recognized that there was a  tag being returned after our JSON response (generated using BaseController's returnJson method).

I copy &amp; pasted some of the output into The Google and found a reference to the YII_DEBUG constant. I checked the value (true) and assumed it was related to devMode. I turned off devMode for this environment and the extra code went away (and YII_DEBUG===false).

I don't suspect that this extra output is expected while using the returnJson() method but I need to get around this. Can I turn off devMode outside of the config file? I really only want to make an exception when calling this method.
I had the same problem. See Brad's response here to so this without messing with devMode: Console script tags garbling up non-html output (e.g. json) when in devMode

It would be nice if this happened automatically when specifically outputting non-html, though.