Learn Courses My Dashboard

Polymorphic JSON Encoding ignores Subclass properties

Hi CWC Community!!

I have a Superclass Person with name and age properties and a Subclass Worker with a job property.

I wanted to Encode a Worker instance to JSON including the job property but apparently, the JSONEncoder only encodes the Person properties.

Does anyone know how I can also encode the job property?