This is the first time I've needed to ask a question - I usually find the answer..
I am able to convert a Doctrine entity to and from JSON with JMS Serializer. My only problem is that when i deserialize from JSON back to the entity, any false boolean values: "boolean_value":false
in the JSON will be set as true
in the Doctrine Entity.
I have narrowed it down to the JMS Serializer. The data is changed in this code.
public function toEntity($entity_name, $input, $inputFormat = 'json') {
// $input is a json string where "boolean_value":false
$serializer = SerializerBuilder::create()->build();
$entity = $serializer->deserialize($json, $entity_name, $inputFormat);
// the output entity's $boolean_value is now true
// $entity->getBooleanValue() === true
return $entity;
}
Let me know if you need anything else.