My Zend_Json is messing up in encoding an object here. I\'m encoding an associative array which has two elements: Element one is another associative array while element 2 is an
This usually happens if you use substr()
or use $somestring[0]
on a utf-8 string which has multibyte letters. Use mb_
prefixed functions to edit this sort of data, then you will not have problem with json_encode()
I see only one possible area where NULL may be returned from Encoder.php. I'd begin debugging by doing some var_dumps inside this function in Zend/Json/Encoder.php
protected function _encodeDatum(&$value)
{
$result = 'null';
if (is_int($value) || is_float($value)) {
$result = (string) $value;
$result = str_replace(",", ".", $result);
} elseif (is_string($value)) {
$result = $this->_encodeString($value);
} elseif (is_bool($value)) {
$result = $value ? 'true' : 'false';
}
return $result;
}
I'm not quite sure why you're HTML string would not be recognized as such, but I might try typecasting it prior to encoding.
array('html' => (string) $yourHtmlStr);
You fix this by updating your PHP version to a version later than version 5.2.7.
There was a serious UTF-8 bug in PHP's json_encode function before that version. See the changelog for more details.
Since you note that you are using PHP version 5.2.9.2 your version should be good :) Have you tried routing the specific contents of the html through PHP's json_encode() manually?
Or maybe through utf8_encode() or utf8_decode()?