You need to make third-party objects serializable without writing a wrapper

I have third-party platforms from which the API needs to be tested using webservices. These APIs accept user objects that are not serializable. Say, for example, some of the APIs look like this.

doSomething(CustomId someId, DBLoaderType type, DBFilter filter, boolean exclude) returns java.util.List<SomeNavigationSystem> 

But these CustomId , DBLoaderType , DBFilter , SomeNavigationSystem are not serializable objects.

Is there a way that I don't need to write any additional classes for all of these classes (there are many such classes) for serialization? If I write one wrapper or equivalent DTO for each business class, then it will be very insecure.

+6
source share
2 answers

I use XSteram , it fixed my problems.

0
source

please check out the Google gson lib under http://code.google.com/p/google-gson/ .

I'm not sure if I fully understood your problem, but if you want to serialize objects that do not implement java.io.Serializable, you should consider json or one of its implementations. Assuming your objects can be serialized from their "nature", gson can serialize them to a string. Your web service diagram may look ugly later on, but it may work. In the end, you will send the lines.

+2
source

Source: https://habr.com/ru/post/888221/


All Articles