-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make JsonNode
serializable?
#18
Comments
I'll have to think about this. In theory, probably. Someone would just need to go ahead and test that it all actually works. One possible problem is that of reference to So I guess I would accept contributions for such feature, yes. |
Why wouldn't you make is serialize to JSON, given that it's faster, more compact, etc.? |
One problem is that there isn't enough contextual information (no ObjectMapper). I guess one could just use default settings to overcome that; but a JsonFactory is still needed. And it would be wasteful and slow to construct one for one time serialization. For that it would be possible to perhaps use Weak- or SoftReference cached copy. So I am open to contibutions as long as they work well and are clean -- you may try to do JSON back serialization if you want. That would most likely use Externalizable interface. |
Is it possible to create a class that extends ObjectNode and implements Serializable to have a JsonNode-like class that supports Serializable functionality? |
Depending on what you are trying to achieve, it's probably better to just use aggregation: create your own class, have ObjectNode as member, do it that way. Using Jackson for replacing JDK serialization, this might be useful: http://www.cowtowncoder.com/blog/archives/2012/08/entry_477.html |
If I used aggregation would I have to create readObject and writeObject methods in order to serialize and de-serialize the ObjectNode member? |
Yes, the root object would need to implement Externalizable, and from that point you can use custom serialization/deserialization, such as just using JSON output. |
I don't think I will work on this -- if anybody else wants to tackle it, feel free to re-open, but only if you actually work on it (not just wish to do that). |
I'd love to see this feature and would be willing to pick it up. From this thread there seem to be two options:
I have two questions:
BTW, I think commit 92223fe is wrongly pointed to this issue #18 , perhaps it references an issue from core? |
@jwgmeligmeyling ok. Just a quick question: what is the use case you are thinking of? On implementation itself: this would be a bit easier with Jackson 3.0 because of #2176. But if you really want to work on this for 2.10, I am ok with it. I'd probably just go with throw-away |
My JPA entities need to be serializable in order for my EntityManager to passivate into a stateful session bean. Some of my entities map a JsonNode from JSONB columns, if the data type foe the JSON input is not fixed for that entity. Now I’m required to implement custom serialization for all entity classes that reference such a JsonNode. Even more tedious is that I cant call defaultSerialization in my custom serializer, because transient fields will always be ignored by JPA and there is apparently no way to work around that. So for JPA entities that means you have to manually searialize/deserialize every field which is tedious and error prone. So Id rather make JsonNode serializable in one way or another :) |
Hello, same problem for me, I'm trying to use EhCache with some Entities containing JsonNode and it's not working because of this issue |
Actually. Now with 2.10 and #2187 I wonder... There would be some limitations, of course:
So... I'll re-consider this issue. |
Hello @cowtowncoder thanks for reconsidering, I think the limitations are fine and understandable but this basic support will help a lot for use cases like the caching one. Thanks, |
ObjectNode
and ArrayNode
serializable?
ObjectNode
and ArrayNode
serializable?JsonNode
serializable?
> Actualiza la versión de Jackson. Al actualizar jackson, también se actualiza una dependencia indirecta: jackson-databind, la cual es necesaria para la serialización de ObjectNode, tipo usado para almacenar objetos de tipo "jsonb" en PostgreSQL a través de Hibernate. Hasta ahora se estaba usando la versión 2.8.8 de jackson-databind. El problema es que esta versión no marca como Serializable a ObjectNode, causando una excepción. Esto se corrigió en la v2.10 (véase FasterXML/jackson-databind#18), por lo cual la actualización corrige este problema.
Would it be possible to make JsonNode
java.io.Serializable
?The text was updated successfully, but these errors were encountered: