protected function makeJsonSafe($data, $base64 = true)
    {
        if (is_array($data)) {
            foreach ($data as $key => $value) {
                $data[$key] = $this->makeJsonSafe($value, $base64);
            }
        }
        if (!$this->isJsonEncodable($data)) {
            if (true === $base64) {
                return 'base64:' . base64_encode($data);
            } else {
                return '--non-parsable-data--';
            }
        }

        return $data;
    }
protected function makeJsonSafe($data, $base64 = true)
    {
        if (is_array($data)) {
            foreach ($data as $key => $value) {
                $data[$key] = $this->makeJsonSafe($value, $base64);
            }
        }
        if (!$this->isJsonEncodable($data)) {
            if (true === $base64) {
                return 'base64:' . base64_encode($data);
            } else {
                return '--non-parsable-data--';
            }
        }

        return $data;
    }
protected function makeJsonSafe ( $ data , $ base64 = true ) { if ( is_array ( $ data ) ) { foreach ( $ data as $ key => $ value ) { $ data [ $ key ] = $ this -> makeJsonSafe ( $ value , $ base64 ) ; } } if ( ! $ this -> isJsonEncodable ( $ data ) ) { if ( true === $ base64 ) { return 'base64:' . base64_encode ( $ data ) ; } else { return '--non-parsable-data--' ; } } return $ data ; }
Base64 encodes any string or array of strings that
cannot be JSON encoded.

@param string|array $data
@param bool         $base64

@return array|string
Base64 encodes any string or array of strings that cannot be JSON encoded .