schmittjoh / serializer

Library for (de-)serializing data of any complexity (supports JSON, and XML)
http://jmsyst.com/libs/serializer
MIT License
2.32k stars 587 forks source link

Uncaught Error when trying to serialise an Enum #1461

Closed CJDennis closed 1 year ago

CJDennis commented 1 year ago
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no

I'm using Symfony 5.4.14 and getting the following error when trying to serialize an Enum.

jms/serializer 3.18.2

[2023-01-11T16:21:25.005494+11:00] php.CRITICAL: Uncaught Error: Object of class HMRX\CoreBundle\Entity\ClinicPharmacistRelationshipTypeEnum could not be converted to string {"exception":"[object] (Error(code: 0): Object of class HMRX\\CoreBundle\\Entity\\ClinicPharmacistRelationshipTypeEnum could not be converted to string at D:\\server\\Apache24\\htdocs\\hmr\\app\\HMRX_App\\vendor\\jms\\serializer\\src\\GraphNavigator\\SerializationGraphNavigator.php:150)"} []

I noticed there was an update to the serializer today, so I updated it but got an identical error.

jms/serializer 3.21.0

[2023-01-11T21:50:19.735874+11:00] php.CRITICAL: Uncaught Error: Object of class HMRX\CoreBundle\Entity\ClinicPharmacistRelationshipTypeEnum could not be converted to string {"exception":"[object] (Error(code: 0): Object of class HMRX\\CoreBundle\\Entity\\ClinicPharmacistRelationshipTypeEnum could not be converted to string at D:\\server\\Apache24\\htdocs\\hmr\\app\\HMRX_App\\vendor\\jms\\serializer\\src\\GraphNavigator\\SerializationGraphNavigator.php:150)"} []

Steps required to reproduce the problem

  1. Serialize data containing an Enum

Expected Result

Actual Result

scyzoryck commented 1 year ago

Hi! Have you enabled Enum support as in documentation?

goetas commented 1 year ago

https://github.com/schmittjoh/JMSSerializerBundle/pull/919