You are here

function JSON::_serialize in Drupal Most Popular 7

Internal Serializer

Parameters

string $key Variable name: @param mixed $value Value of the variable @access private @return string Serialized variable

1 call to JSON::_serialize()
JSON::serialize in modules/mostpopular_disqus/disqusapi/json.php
Serialize

File

modules/mostpopular_disqus/disqusapi/json.php, line 342

Class

JSON
JSON

Code

function _serialize($key = '', &$value) {
  $r = '';
  if ($key != '') {
    $r .= "\"{$key}\" : ";
  }
  if (is_numeric($value)) {
    $r .= '' . $value . '';
  }
  else {
    if (is_string($value)) {
      $r .= '"' . $this
        ->toString($value) . '"';
    }
    else {
      if (is_object($value)) {
        $r .= $this
          ->serialize($value);
      }
      else {
        if (is_null($value)) {
          $r .= "null";
        }
        else {
          if (is_bool($value)) {
            $r .= $value ? "true" : "false";
          }
          else {
            if (is_array($value)) {
              foreach ($value as $k => $v) {
                $f[] = $this
                  ->_serialize('', $v);
              }
              $r .= "[" . implode(",", $f) . "]";
              unset($f);
            }
          }
        }
      }
    }
  }
  return $r;
}