Do Jackson and Gson directly implement the standard JSR-353?
Asked Answered
S

3

13

I couldn't find an answer to my question on the net (maybe I did not search well enough, since I am still a novice on this).

Could anyone tell me if Jackson and Gson implement the standard JSR 353: Java™ API for JSON Processing. I would like to write using standard code.

Seek answered 16/1, 2015 at 10:57 Comment(4)
353 or 535? If you are talking about javax.json (ie, JSR 353) then the answer is no, not directlyLivvie
Yes can you tell me how can this be done using Jackson ?Seek
Similar: What are the API that does implement JSR-353 (JSON)Vervain
On sister site Software Recommendations Stack Exchange, see: Actual implementation of JSR-353 (JSON)? – Basil Bourque May 28 '18 at 22:30Vervain
H
9

This link has the reply (apparently by the Jackson founder), and it essentially says that Jackson doesn't implement the JSR:

Reply by Tatu Saloranta on January 26, 2014 at 8:21pm

I am not a big fan of JSR-353 (I consider it a big fail) and unless something drastic happens, Jackson core will not implement JSR-353. There is no benefit from data-binding to use it; both because implementations do not bring anything to table (none are particularly fast), nor implement all that databind needs (base64 encoding, multi-format support capabilities) -- and worst of all ALL existing (de)serializers would need to be rewritten use new, less capable API. And baseline for Jackson would need to become Java 8. So I see no upside.

However, the reverse is possible; it is possible to have a JSR-353 implementation based on Jackson streaming package, and this has been done already:

https://github.com/pgelinas/jackson-javax-json.

Or, to make Jackson capable of reading/writing JSR-353 JSON object types, a simple datatype module is needed. I wrote one a while back:

https://github.com/FasterXML/jackson-datatype-jsr353

So if Java developers end up following "the standard" track, Jackson can play along.

Google didn't (couldn't?) vote on the JSR, and I couldn't find anything on Gson's roadmap either to suggest that they'd want to comply.

Hypogeous answered 16/1, 2015 at 11:11 Comment(4)
Can this be done using github.com/pgelinas/jackson-javax-json ? i did not understand it that well to decide if i should go into this direction. Also, could you tell me if there is out there a JSON api (like jackson,gson ..) that does implement the standard jsr-353 ?Seek
@maher.belkh Genson implements JSR 353 natively and other stuff that is not part of the JSR.Reset
jackson-users.ning.com/forum/topics/… is now a dead linkFidellas
@NicolasLacombe, I have just updated the link to the Wayback Machine's one.Chigger
V
9

tl;dr

Use:

Update

The other two Answers are correct, but outdated. As they explain, Jackson does not directly implement any JSR.

However:

So you may indeed now write in standard code using JSON libraries other than Jackson.

Vervain answered 11/2, 2019 at 20:20 Comment(0)
P
6

No, neither implements this API natively, nor has plans (that I know of) to implement it. As far as JCP standards go, this is DOA; it offers very little (dumbed-down streaming API, no data-binding at all), and there is very little incentive for anyone to implement it, except to add compatibility check-box for set of JSRs implemented.

There is a Jackson-based JSR-353 implementation available at https://github.com/pgelinas/jackson-javax-json/ however, if you really think it is good idea to base your code on this API.

Palawan answered 31/3, 2015 at 16:0 Comment(2)
This Answer is now outdated. JSR 353 defines the foundation for JSON parsing. JSR 367 builds upon that to provide binding capabilities. See the project page for JSR 367. Yasson is the reference implementation.Vervain
No. Neither JSR-353 nor JSR-367 are widely used by frameworks, although some are adding alternate bindings to use them. These specs and implementations are not close (nor likely ever be) to Gson or Jackson level of maturity or features, and the only selling is the insistence of "but it's THE STANDARD". Users are of course free to use whatever they want to, but I feel it is bad to drink Oracle Kool-Aid blindly.Palawan

© 2022 - 2024 — McMap. All rights reserved.