1

I have the following classes

/**
 * @Discriminator(field = "type", map = {
 *      "b":"B",
        "c":"C",
 * })
 */
abstract class A {}

class B extends A { ... }
class C extends A {
     /**
     * @var A
     * @Serializer\Type("A")
     */
      $a
}

now when I serialize an object of class C:

The discriminator field name "type" for base-class "A" was not found in input data.

Any idea what am I doing wrong here? I am using JMS serializer.

EDIT

I am getting this exception when I try to deserialize the serialized object.

Obaid Maroof
  • 1,523
  • 2
  • 19
  • 40

1 Answers1

1

An abstract class can't be initialized and therefor not deserialized. If you need your class A, you should change it to a normal class and not beeing abstract.

I had a similar problem a year ago, this is my solution: JMS Serializer Deserialize with abstract parent class

Community
  • 1
  • 1
con
  • 2,358
  • 25
  • 33