FasterXML / jackson-future-ideas

Repository for SOLE PURPOSE of issue tracker and Wiki for NEW IDEAS. Please: NO BUG REPORTS.
18 stars 6 forks source link

JSON-B implementation #19

Open sercasti opened 7 years ago

sercasti commented 7 years ago

If we all work together and contribute, I think we can easily make a new version of Jackson that implements the new RFC.

cowtowncoder commented 7 years ago

I am not at all opposed to increasing inter-operability, but from what I remember there were some fundamental challenges in making Jackson implement JSON-B "natively". I think one such issue is question of JSON-P: my understanding was that JSON-B operates strictly on JSON-P implementation, so ideally jackson-core would also need to implement JSON-P. This in turn seemed difficult to achieve efficiently (wrapping approach is not difficult but adds non-trivial overhead); and form my perspective there is very little benefit from JSON-P as a standard (being a subset of what Jackson streaming API offers, and not having much in way of extensibility options).

However if someone wants to try it out I have nothing against that. Forking jackson-databind would probably make sense. Since Jackson 2.x does not require Java 8 as baseline, I think that realistically fork should be from branch that is for Jackson 3.0 -- currently there is separate planning branch (ng-3.0), but master will switch over in a month or two.

eolivelli commented 6 years ago

News on this? I would like to use json-b annotations on beans handled with Jackson. Do you think this would be possible?

cowtowncoder commented 6 years ago

No news here. But one thing I'll point is that what you suggest is slightly different, an easier to implement than actual JSON-B implementation: similar to how JAXB annotations are supported via extension module (jackson-module-jaxb-annotations) it might well be easy to support these annotations.

So it might make sense to create a separate issue, so outline possibility of this as a distinct thing.

xtroce commented 3 years ago

Hi, is there any news on fasterxml.jackson-databind to comply to the json-b standard yet... thus a package that handles the annotations defined in JSR-367 as mentioned by @cowtowncoder? https://jcp.org/en/jsr/detail?id=367

cowtowncoder commented 3 years ago

@xtroce Volunteers welcome! I am not aware of anyone tackling this yet.

Unfortunately I do not have time myself (or specific use case) to do that, but adding support for annotations could be a fun project for someone; for example for a hackathon. Would have been something for Hacktoberfest participants.

Thihup commented 3 years ago

I'm willing to make a Jackson JSON Binding that is TCK compliant. I don't know which would be all the correct ways to do it, but there is an old project that converting to the Jakarta namespace passes almost 50% of the TCK.

This is the project: https://github.com/devcon5io/jackson-jsonb-provider

I actually don't know if I can just fork it and can add the fixes or if I need to reimplement it in a new package. After that, I don't know if the project could be part of the FasterXML repo.

But I guess this is a start :)

Thihup commented 3 years ago

Looks like it would need a rewrite to actually use the JSONP. So I'll start by updating the project https://github.com/pgelinas/jackson-javax-json to the Jakarta namespace and hope that it can pass the TCK.

cowtowncoder commented 3 years ago

@Thihup yes, the close coupling of JSON-B to underlying JSON-P which makes it not possible for main jackson-databind to directly implement JSON-B. It would, however, be possible to implement JSON-P on jackson streaming (jackson-core), which I think is what you are planning. I'd be interested in seeing what comes out of it at any rate.

Thihup commented 3 years ago

That project implemented partially the JSON-P 1.0, so it misses the new APIs added in 1.1. I've forked the project and started fixing the issues here https://github.com/Thihup/jackson-jakarta-jsonp/tree/jakartaee-9.

I still need to learn what is JsonPointer to be able to implement that stuff correctly.

There is another problem that I'm struggling to know the best way to fix: The JSON-P provides an API to create a JSON programmatically and it compares the JSON with the result of parsing a JSON file. In most cases, it works, but there is an edge-case when the reader interprets a number as IntNode and the code is expecting a BigIntegerNode, so the comparison fails.

Running the TCK with my fork:

     [echo] Completed running 187 tests.
     [echo] Number of Tests Passed = 151
     [echo] Number of Tests Failed = 36
     [echo] Number of Tests with Errors = 0
cowtowncoder commented 3 years ago

Existence of TCK is nice -- are those actually freely available these days? Either way, good way to compare. I wonder if @pgelinas has context here to perhaps help.

Thihup commented 3 years ago

Existence of TCK is nice -- are those actually freely available these days?

Yes, Oracle donated all Java EE stuff to Eclipse Foundation (now under name Jakarta EE), including the TCK, so it is free ;) https://jakarta.ee/specifications/jsonp/2.0/

oliviercailloux commented 2 years ago

Related: eclipse-ee4j/jsonb-api#251