Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can serialVersionUID be ignored when serializing to JSON?

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!)

like image 625
ankitjaininfo Avatar asked Jan 02 '15 07:01

ankitjaininfo


Video Answer


1 Answers

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.

like image 109
Stephen C Avatar answered Sep 21 '22 18:09

Stephen C