3

So i know it might sound wrong / bad but this is the situation i have

legacy code that cannot be modified. class A it is a bean class that has been serialize from JSON class B is part of class C, i'm getting class A and i need to add him as class B into class C.

Is there any good way instead of using copy constructor ?

Class A {

    String a;
    String b;
}

Class B {

    String a;
    String b;
}

Class C {
    ..
    ..
    ..
    B b;
}
USer22999299
  • 5,284
  • 9
  • 46
  • 78

1 Answers1

2

you may want to try this, here you need to extend the ObjectInputStream and use it to read the serialized file. you can specify the new class into which you wan to deserialize. https://stackoverflow.com/a/3916282/1129313

Community
  • 1
  • 1
Garry
  • 4,493
  • 3
  • 28
  • 48