class MyTypeToSerialize {
MyType2 a; // "main" field
}
class MyType1 extends MyTypeToSerialize {
MyType3 b; // service fiels
}
If you just want the field MyType2 a
to be serialized/deserialized then use MyTypeToSerialize
(you don't need a custom serializer or deserialiser)
Edit: @Brian Roach's suggestion is better and easier solution:
class MyType1 {
MyType2 a; // "main" field
transient MyType3 b; // service fiels
}
Edit2:
So I need to serialize only "main" fields and derive service ones from them.
So use on of the suggestions above.
I know I can use transient keyword for this specific case. But the question is about writing serializers.
Why do you think you need serializers?