Based on a question on Java's serialVersionUID, is it necessary to define serialVersionUID when the serialization is JSON?
private static final long serialVersionUID = 234239427349L;
I understand that when a object is binary serialized (RPC, etc), the framework adds class metadata to know which version it got serialized to and reject if it mismathces. If the JSON does not have any serial version field (_v), then this appears useless. (although SONAR give warning!)
It is not necessary. It can be ignored. The serialVersionUID
field is not relevant when serializing or deserializing JSON.
In fact, that field is only relevant if you are using the Java object serialization protocol; i.e. the standard ObjectInputStream
and ObjectOutputStream
classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With