hypersistence-utils icon indicating copy to clipboard operation
hypersistence-utils copied to clipboard

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

Open derekm opened this issue 7 years ago • 5 comments

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.

derekm avatar May 02 '18 14:05 derekm

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

vladmihalcea avatar May 02 '18 14:05 vladmihalcea

I may try to carve out some time to assist!

derekm avatar May 04 '18 19:05 derekm

Cool, thanks

vladmihalcea avatar May 04 '18 19:05 vladmihalcea

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

jwgmeligmeyling avatar Jul 10 '19 10:07 jwgmeligmeyling

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.

vladmihalcea avatar Jul 10 '19 11:07 vladmihalcea