You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In JsonResponse::setDatajson_encode is called then and then JsonEncode::update is called to deal with setting up the content.
If no JS callback is specified and json_encode fails -- returns false -- Response::setContent throws an UnexpectedValueException saying that only strings or objects that have a __toString method are allowed.
I ran into this with an invalid UTF8 character that came out of MySQL.
Seems like this could be improved by checking for a false result on the json_encode call and using json_last_error to generate a nicer error message.
Would that be too detailed for JsonResponse? Should it be up to the caller to make sure they give JsonResponse::setData something valid? Even if it's very hard to tell that something may not work?