You are here

function views_json_encode_special_chars in Views Datasource 5

Encodes special JSON characters in string

Parameters

string $input:

Return value

string

2 calls to views_json_encode_special_chars()
views_json_exhibit_render in ./views_json.module
views_json_simple_render in ./views_json.module

File

./views_json.module, line 262
views_json.module - provides Views plugin for rendering node content as JSON.

Code

function views_json_encode_special_chars($input) {
  $output = str_replace(chr(92), '\\', $input);
  $output = str_replace(chr(47), '\\/', $output);
  $output = str_replace('"', '\\"', $output);
  $output = str_replace(chr(8), '\\b', $output);
  $output = str_replace(chr(12), '\\f', $output);
  $output = str_replace(chr(13) . chr(10), '\\n', $output);
  $output = str_replace(chr(10), '\\n', $output);
  $output = str_replace(chr(13), '\\r', $output);
  $output = str_replace(chr(9), '\\t', $output);
  return check_plain(strip_tags($output));
}