I am creating a symfony2 project and using the JMS serializer to serialize my object to store the database (I know this is not the best way).
But now my problem is when I change the property of my object and deserialize the Json string, the JMS serializer ignores non-existent properties, and does not throw an error, which is actually great. But I would like to register such an event.
Below is an example illustrating my question
Json string from my database:
$dataToBeDeserialized = {"title":"testing123","text":"Lorem Ipsum"}
TestClass:
protected title; protected text;
Deserialization Method:
$this->serializer = SerializerBuilder::create()->build(); $this->serializer->deserialize($dataToBeDeserialized, 'TestClass', 'json');
It leads to:
TestClass { title: "testing123", text: "Lorem Ipsum"}
But when I change my Testclass and rename (or delete) the title, say βtitle2β, the deserializer ignores the βtitleβ attribute in the Json line. and this leads to:
TestClass { title2: "", text: "Lorem Ipsum"}
Well no problem. The data in the database is incorrect. But I would like to register this problem. How can I do it? I do not want, if possible, to use the JMS serializer code (since I can no longer update it). And finding empty properties in my TestClass is also not the best way, since they can be null.