original_string: protected function castValueAsJson($value)
      {
          $value = $this->asJson($value);
  
          if ($value === false) {
              throw new \RuntimeException(
                  sprintf(
                      "Unable to encode value [%s] for element [%s] to JSON: %s.",
                      $this->getName(),
                      get_class($this),
                      json_last_error_msg()
                  )
              );
          }
  
          return $value;
      }
code: protected function castValueAsJson($value)
      {
          $value = $this->asJson($value);
  
          if ($value === false) {
              throw new \RuntimeException(
                  sprintf(
                      "Unable to encode value [%s] for element [%s] to JSON: %s.",
                      $this->getName(),
                      get_class($this),
                      json_last_error_msg()
                  )
              );
          }
  
          return $value;
      }
code_tokens: protected function castValueAsJson ( $ value ) { $ value = $ this -> asJson ( $ value ) ; if ( $ value === false ) { throw new \ RuntimeException ( sprintf ( "Unable to encode value [%s] for element [%s] to JSON: %s." , $ this -> getName ( ) , get_class ( $ this ) , json_last_error_msg ( ) ) ) ; } return $ value ; }
docstring: Cast the given value to JSON.
  
  @param mixed $value
  @return string
docstring_tokens: Cast the given value to JSON .