Question: why does JsonNode not implement

Skip to first unread message

Thijs Petter

Apr 1, 2016, 10:38:10 AM4/1/16
to jackson-user
Hello all,

I have not found any json library where the generic JsonNode class implements, 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 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

Tatu Saloranta

Apr 1, 2016, 10:50:14 AM4/1/16
to jackson-user
One reason is because `JsonNode` does not know how to serialize itself with only information available at serialization: there is no ObjectMapper or JsonGenerator to use; latter is the component it must have to serialize itself (and contents if any). It can not and should try to instantiate either (how should they be configured?); and static singletons tend to cause problems in bigger systems (one part tries to go and configure them one way, another different)

Providing for mechanism to do this (via ThreadLocal or whatnot) would be lots of additional work, to support a broken system (JDK serialization has been considered broken and anti-pattern for past 15 years or so).

So it's just a feature that is very hard to support and has little upside.

-+ Tatu +-

You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
For more options, visit

Reply all
Reply to author
0 new messages