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;
    }
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;
    }
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 ; }
Cast the given value to JSON.

@param mixed $value
@return string
Cast the given value to JSON .