You are here

function sendgrid_json_encode in SendGrid Integration 6

Helper function for json encoding

Parameters

$var:

Return value

string json encoded string

1 call to sendgrid_json_encode()
sendgrid_integration_drupal_mail_wrapper in ./sendgrid_integration.module

File

./sendgrid_integration.module, line 196
Main module file for SendGrid Integration.

Code

function sendgrid_json_encode($var) {

  // The PHP version cannot change within a request.
  static $php530;
  if (!isset($php530)) {
    $php530 = version_compare(PHP_VERSION, '5.3.0', '>=');
  }
  if ($php530) {

    // Encode <, >, ', &, and " using the json_encode() options parameter.
    return json_encode($var, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
  }

  // json_encode() escapes <, >, ', &, and " using its options parameter, but
  // does not support this parameter prior to PHP 5.3.0.  Use a helper instead.
  include_once drupal_get_path('module', 'sendgrid_integration') . '/json-encode.inc';
  return sendgrid_json_encode_helper($var);
}