diff --git a/README.md b/README.md index 896832d..1ba340d 100644 --- a/README.md +++ b/README.md @@ -176,12 +176,28 @@ dunglas_doctrine_json_odm: bar: App\SomethingElse\Bar ``` +Or, the same config in PHP for better type-safety, e.g. `config/packages/doctrine_json_odm.php`: + +```php +typeMap('foo', Foo::class); + $config->typeMap('bar', Bar::class); +}; +``` + With this, `Foo` objects will be serialized as: ```json { "#type": "foo", "someProperty": "someValue" } ``` + + Another option is to use your own custom type mapper implementing `Dunglas\DoctrineJsonOdm\TypeMapperInterface`. For this, just override the service definition: ```yaml