M
M
mitaichik2017-02-25 02:05:06
Java
mitaichik, 2017-02-25 02:05:06

Gson doesn't serialize methods?

I have an object, there is a getter. I would like gson to serialize it. After reading the documentation, I realized that this is not possible. Is it so?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Zagaevsky, 2017-02-25
@mitaichik

The best way is to write a Serializer and do it manually there.

D
Dmitry, 2017-02-25
@dsv

Data is serialized, not methods. Those. in some form, the state (data) of an object is stored, and then it can be loaded into an object of the same class. It is the class that will define the methods (behavior). In this case, the class must be known in the application in which the deserialization is performed, and the SerialVersionUID must match what the object class had during serialization.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question