Zend_JSON:Encode messing up - why?

前端 未结 3 2001
囚心锁ツ
囚心锁ツ 2021-02-13 02:50

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

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-13 03:33

    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);
    

提交回复
热议问题