source/Core/StrRegular.php
public function jsonEncode($data)
    {
        if (is_array($data)) {
            $ret = "";
            $blWasOne = false;
            $blNumerical = true;
            reset($data);
            while ($blNumerical && $key = key($data)) {
                $blNumerical = !is_string($key);
            }
            if ($blNumerical) {
                return '[' . implode(',', array_map([$this, 'jsonEncode'], $data)) . ']';
            } else {
                foreach ($data as $key => $val) {
                    if ($blWasOne) {
                        $ret .= ',';
                    } else {
                        $blWasOne = true;
                    }
                    $ret .= '"' . addslashes($key) . '":' . $this->jsonEncode($val);
                }

                return "{" . $ret . "}";
            }
        } else {
            return '"' . addcslashes((string) $data, "\r\n\t\"\\") . '"';
        }
    }
public function jsonEncode($data)
    {
        if (is_array($data)) {
            $ret = "";
            $blWasOne = false;
            $blNumerical = true;
            reset($data);
            while ($blNumerical && $key = key($data)) {
                $blNumerical = !is_string($key);
            }
            if ($blNumerical) {
                return '[' . implode(',', array_map([$this, 'jsonEncode'], $data)) . ']';
            } else {
                foreach ($data as $key => $val) {
                    if ($blWasOne) {
                        $ret .= ',';
                    } else {
                        $blWasOne = true;
                    }
                    $ret .= '"' . addslashes($key) . '":' . $this->jsonEncode($val);
                }

                return "{" . $ret . "}";
            }
        } else {
            return '"' . addcslashes((string) $data, "\r\n\t\"\\") . '"';
        }
    }
public function jsonEncode ( $ data ) { if ( is_array ( $ data ) ) { $ ret = "" ; $ blWasOne = false ; $ blNumerical = true ; reset ( $ data ) ; while ( $ blNumerical && $ key = key ( $ data ) ) { $ blNumerical = ! is_string ( $ key ) ; } if ( $ blNumerical ) { return '[' . implode ( ',' , array_map ( [ $ this , 'jsonEncode' ] , $ data ) ) . ']' ; } else { foreach ( $ data as $ key => $ val ) { if ( $ blWasOne ) { $ ret .= ',' ; } else { $ blWasOne = true ; } $ ret .= '"' . addslashes ( $ key ) . '":' . $ this -> jsonEncode ( $ val ) ; } return "{" . $ ret . "}" ; } } else { return '"' . addcslashes ( ( string ) $ data , "\r\n\t\"\\" ) . '"' ; } }
wrapper for json encode, which does not work with non utf8 characters

@param mixed $data data to encode

@return string
wrapper for json encode which does not work with non utf8 characters