- Provide JSON binding i.e. marshalling and un-marshalling to and from Java objects
- Eclipselink will server as Reference Implementation
- Supports Java object model to JSON mapping via annotations
- Supports default mapping for implicit transformations b/w Java model and JSON (without annotation/additional metadata)
- Produce JSON schema from Java classes
- Support further customization of default mapping mechanisms as well as partial mapping (part of JSON doc needs to be mapped to Java model)
- Will integrate with JSON-P and probably with JSON API JEP 198 (Java SE API for JSON processing) if needed
Please Note That
- This is just a quick test of the JSON-B implementation in a Java EE 7 container
- It not an ideal scenario, i.e. it does not demonstrate integration of the JSON-B spec with a Java EE container (at least not yet).
- I am not aware of Java EE 8 builds which ship with JSON-B as of right now.
From a (Java EE 8) Container Integration Perspective (Near Future)
The integration should be seamless and transparent — the way it is in case of JSON-P and JAXB annotated classes, i.e. you will ideally be able to annotate your Java classes using JSON-B annotations and expect them to be serialized or deserialized automatically by the container (e.g. JAX-RS runtime).
- Have a simple POJO
- Expose POJO using JAX-RS (GET, POST)
- Use JAX-RS Message Body Reader and Writer – this overrides the default JSON-P providers and leverage JSON-B API here (simply use the default mapping feature) for transformation
- Repeat the same for a ‘List of’ POJOs
Github project available here – this is not a Maven project. Ideally, you would want to clone into NetBeans, then build and run on a Java EE 7 container. Make sure to have RI JAR in WAR (details below).
To Be Noted
- I could not grab the Maven artifact of the JSON-B API JAR (maybe I am missing something), so ended up including the JSON-B API sources in the WAR itself.
- Same case with the RI – download it directly from here.
What’s Really Important
- You can grab the draft specification, API sources, and javadocs from here (the API sources itself are a part of the ZIP downloaded using this link).
- Check out the Reference Implementation here