for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Tanigami\DoctrineJsonUnescapedType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\JsonType;
class JsonUnescapedType extends JsonType
{
/**
* {@inheritdoc}
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform = null)
if (null === $value) {
return null;
}
$encoded = json_encode($value, JSON_UNESCAPED_UNICODE);
if (JSON_ERROR_NONE !== json_last_error()) {
throw ConversionException::conversionFailedSerialization($value, 'json', json_last_error_msg());
return $encoded;
public function getName()
return 'json_unescaped';