You are here

public function ServicesJSONFormatter::render in Services 7.3

Render data to the string.

Parameters

$data: Data to render

Return value

string

Overrides ServicesFormatterInterface::render

1 call to ServicesJSONFormatter::render()
ServicesJSONPFormatter::render in servers/rest_server/includes/ServicesFormatter.inc
Render data to the string.
1 method overrides ServicesJSONFormatter::render()
ServicesJSONPFormatter::render in servers/rest_server/includes/ServicesFormatter.inc
Render data to the string.

File

servers/rest_server/includes/ServicesFormatter.inc, line 16

Class

ServicesJSONFormatter

Code

public function render($data) {

  // json_encode doesn't give valid json with data that isn't an array/object.
  if (is_scalar($data)) {
    $data = array(
      $data,
    );
  }
  return defined('JSON_PARTIAL_OUTPUT_ON_ERROR') ? str_replace('\\/', '/', json_encode($data, JSON_PARTIAL_OUTPUT_ON_ERROR)) : str_replace('\\/', '/', json_encode($data));
}