public function visitArray($data, array $type, Context $context)
 {
     $types = array('NULL', 'string', 'integer', 'boolean', 'double', 'float', 'array', 'ArrayCollection');
     if (is_array($data) && count($type['params']) === 1 && !empty($type['params'][0]['name'])) {
         foreach ($data as $key => $value) {
             if (is_scalar($value) && !in_array($type['params'][0]['name'], $types)) {
                 /** @var DeserializationContext $context */
                 $context->useDoctrineConstructor();
                 $data[$key] = array('id' => $value);
             }
         }
     }
     return parent::visitArray($data, $type, $context);
 }
Example #2
0
 /**
  * Deserialize Hash object
  *
  * @param JsonDeserializationVisitor $visitor Visitor
  * @param array                      $data    Data
  * @param array                      $type    Type
  * @param Context                    $context Context
  * @return Hash
  */
 public function deserializeHashFromJson(JsonDeserializationVisitor $visitor, array $data, array $type, Context $context)
 {
     return new Hash($visitor->visitArray($data, $type, $context));
 }