vladmihalcea / hypersistence-utils

The Hypersistence Utils library (previously known as Hibernate Types) gives you Spring and Hibernate utilities that can help you get the most out of your data access layer.
Apache License 2.0
2.38k stars 365 forks source link

Use newer JSON-P & JSON-B standards as alternative to Jackson #29

Open derekm opened 6 years ago

derekm commented 6 years ago

Jackson is being obsoleted by JSON-P & JSON-B, and the Java community will be moving forward with the industry standards.

It would be nice to see JSON-P's JsonObject or JsonStructure used instead of Jackson's JsonNode.

It is also possible that adding in JSON-B could allow for typesafe population of POJOs from PostgreSQL jsonb columns, but I can't speak as to whether Hibernate could allow for this level of generics, although I would think it could.

vladmihalcea commented 6 years ago

That can be done. It only requires changing the JavaTypeDescriptor. However, I have no time to do it now.

derekm commented 6 years ago

I may try to carve out some time to assist!

vladmihalcea commented 6 years ago

Cool, thanks

jwgmeligmeyling commented 5 years ago

The JSON-P equivalent for JsonNode seems to be JsonValue instead of JsonStructure. However, just swapping out the implementation of Jackson with JSON-B/JSON-P will mean that any users that rely on JsonNode serialisation, serialization of beans mapped with Jackson annotations, or users that provide a custom ObjectMapper will run into compatibility issues. Therefore the JSON-B/JSON-P alternative should probably use a different type name and live under a different package.

@vladmihalcea What is your preference w.r.t. the new type names and package name for the JSON-B/JSON-P types?

I've done some initial testing with swapping out Jackson for JsonB/P. Most of the tests are passing but it obviously still needs the aforementioned structural rework: https://github.com/vladmihalcea/hibernate-types/compare/master...JWGmeligMeyling:feature/29

Note: some users may also like that the JsonValue implementations are Serializable: #25

vladmihalcea commented 5 years ago

I new type would be fine for JSON-P, like jsonb-p and json-p. The new type will not use Jackson, so it should not affect users that mapped JsonNode on their entities.