original_string: public function serialize($value)
      {
          $this->reset();
          $serializedData = $this->serializeData($value);
          $encoded = json_encode($serializedData, $this->calculateEncodeOptions());
          if ($encoded === false || json_last_error() != JSON_ERROR_NONE) {
              if (json_last_error() != JSON_ERROR_UTF8) {
                  throw new JsonSerializerException('Invalid data to encode to JSON. Error: ' . json_last_error());
              }
  
              $serializedData = $this->encodeNonUtf8ToUtf8($serializedData);
              $encoded = json_encode($serializedData, $this->calculateEncodeOptions());
  
              if ($encoded === false || json_last_error() != JSON_ERROR_NONE) {
                  throw new JsonSerializerException('Invalid data to encode to JSON. Error: ' . json_last_error());
              }
          }
          return $this->processEncodedValue($encoded);
      }
code: public function serialize($value)
      {
          $this->reset();
          $serializedData = $this->serializeData($value);
          $encoded = json_encode($serializedData, $this->calculateEncodeOptions());
          if ($encoded === false || json_last_error() != JSON_ERROR_NONE) {
              if (json_last_error() != JSON_ERROR_UTF8) {
                  throw new JsonSerializerException('Invalid data to encode to JSON. Error: ' . json_last_error());
              }
  
              $serializedData = $this->encodeNonUtf8ToUtf8($serializedData);
              $encoded = json_encode($serializedData, $this->calculateEncodeOptions());
  
              if ($encoded === false || json_last_error() != JSON_ERROR_NONE) {
                  throw new JsonSerializerException('Invalid data to encode to JSON. Error: ' . json_last_error());
              }
          }
          return $this->processEncodedValue($encoded);
      }
code_tokens: public function serialize ( $ value ) { $ this -> reset ( ) ; $ serializedData = $ this -> serializeData ( $ value ) ; $ encoded = json_encode ( $ serializedData , $ this -> calculateEncodeOptions ( ) ) ; if ( $ encoded === false || json_last_error ( ) != JSON_ERROR_NONE ) { if ( json_last_error ( ) != JSON_ERROR_UTF8 ) { throw new JsonSerializerException ( 'Invalid data to encode to JSON. Error: ' . json_last_error ( ) ) ; } $ serializedData = $ this -> encodeNonUtf8ToUtf8 ( $ serializedData ) ; $ encoded = json_encode ( $ serializedData , $ this -> calculateEncodeOptions ( ) ) ; if ( $ encoded === false || json_last_error ( ) != JSON_ERROR_NONE ) { throw new JsonSerializerException ( 'Invalid data to encode to JSON. Error: ' . json_last_error ( ) ) ; } } return $ this -> processEncodedValue ( $ encoded ) ; }
docstring: Serialize the value in JSON
  
  @param  mixed $value
  @return string JSON encoded
  @throws JsonSerializerException
docstring_tokens: Serialize the value in JSON