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