Hello all,
I have not found any json library where the generic JsonNode class implements java.io.Serializable, and I don't really understand why.
My use case we have an Akka runtime environment, with some parts written in Scala, and a large part written in Java. We receive generic JSON structures through a REST api, and need to pass them on from one actor to another, and they are also persisted in event streams.
Akka uses plain Java serialization for this, and when my class implements java.io.Serializable it works fine, except for the JsonNode in it.
public class GenericDataEvent implements Serializable {
private String action; // E.g., insert, update, delete
private JsonNode value; // The thing that was inserted/updated/deleted
}
Perhaps it is straightforward to serialize the json, but I'd rather not write any code for it, it would be much more convenient if JsonNode would implement Serializable.
I have noticed that the scala library (json4s) implements Serializable, however that does not work pleasantly inside the Java side of the house.
So my question is: is there any specific reason that JsonNode does not implement java.io.Serializable?