Wednesday Jan 14, 2015

Calling All JSON Enthusiasts: Join JSON-P 1.1!

As many of you know the initial wave of Java EE 8 JSRs are now fully launched for a little while now, including the platform JSR itself, CDI 2, JSON-B, JMS 2.1, Servlet 4, JAX-RS 2.1, MVC and JSF 2.3. More recently three other Java EE 8 JSRs have been launched - Java EE Security, Java EE management and JSON-P 1.1 (more specifically the Java API for JSON Processing 1.1, launched as JSR 374). All three are now in the process of forming their initial expert groups. JSON-P 1.1 lead Kin-man Chung is specifically looking out for folks to join his expert group - go to the JSR page linked above to nominate yourself!

Although it's currently slated to be a point release, there is some very interesting work that may happen in JSON-P 1.1. Here is a very high level summary of the items currently under consideration:

  • Adding support for JSON Pointer.
  • Adding support for JSON Patch.
  • For those unaware, JSON Pointer and JSON Patch are both recently finalized IETF specifications. To go along with the JSON Pointer and JSON Patch work JSON-P 1.1 will also add support for editing/transformation operations to the JSON object model API, quite possibly using the builder pattern.
  • You can actually already use Java SE 8 streams and lambdas with JSON-P. JSON-P 1.1 will explore if Java SE 8 support may be improved across the API further.

Kin-man did an excellent job overviewing the possibilities in his JavaOne 2014 talk that you can see for yourself below.

Note that you can always participate in a JSR without officially being part of the expert group by simply subscribing to the JSR user alias. In case of JSON-P that alias is users at json-processing-spec dot java dot net - go to the JSON-P java.net project page to subscribe. Also remember that you can contribute on an even more lightweight format through Adopt-a-JSR.

Tuesday Jul 15, 2014

Java API for JSON Binding (JSON-B)

JSON-P (Java API for JSON Processing - JSR-353) provides a portable standard solution to parse, generate, transform, and query JSON using 2 APIs, a streaming API and an object model API based on the streaming API. JSON-P was one of the API added to Java EE7.

But clearly JSON parsing and JSON generation was a first step and only a (important) part of the global equation. To convert Java objects from/to JSON representation, you have to rely on different solutions, different frameworks such as EclipseLink MOXy or Google GSON to just name two! The issue is that, obviously, all those frameworks are all different since there is no standard in that space. This was also clearly reflected in the Java EE 8 Community Survey as JSON Binding was the most asked feature!

Oracle plans to submit a new JSR to solve that particular problem, i.e. the 'Java API for JSON Binding' JSR. The JSON-B JSR aims to define a standard binding layer for converting Java objects to JSON messages and vice versa. JSON-B will leverage and complement JSON-P (JSR 353). The draft proposal for the JSON-B JSR has just been made public to gather feedback and recruit supporters before it is submitted to the JCP in August. JSON-B will be targeted for inclusion in Java EE 8 but will also work with Java EE 7. And timing wise, it is aligned with the current Java EE 8 roadmap.

It's summer time and August isn't that far, so make sure to read the proposal and gives us your feedback quickly!

Friday Nov 15, 2013

MOXy is the New Default JSON-Binding Provider in GlassFish 4

When I talk about JAX-RS 2, JSON-P and Java EE 7 a surprising number of people seem to assume that GlassFish and Jersey does not support JSON binding and just supports lower level JSON processing. It is in fact correct that Java EE 7 has standardized JSON processing (via JSON-P) but not a JSON binding API yet (although such a standardized API is a very strong consideration for Java EE 8 and would build upon the JSON-P work). However Jersey, the popular JAX-RS reference implementation, has long had strong support for JSON binding via MOXy, Jackson and Jettison (now it also has support for JSON-P of course). In fact, in GlassFish/Jersey the default JSON binding provider is MOXy. If you are not familiar with MOXy, it is a very interesting project part of EclipseLink (the JPA reference implementation) that translates JAXB annotations to JSON. In a code driven post, Blaise Doughan of the Oracle EclipseLink team explains the details of using MOXy with JAX-RS in GlassFish.

For more details on Jersey's support for JSON, you should check out the very well-written documentation.

Thursday Aug 08, 2013

An Overview of JSON-P

JSON is quickly becoming the de facto data interchange format on the web, especially with powerful JavaScript clients, Ajax, REST and HTML 5 WebSockets. This is why JSON-P (or more formally the Java API for JSON Processing) is such a key part of the Java EE 7 release. It is intended to provide a standard, vendor-neutral, ubiquitous solution for parsing, generating and querying JSON. In a brief OTN article, JSON-P specification lead Jitendra Kotamraju (or Jitu as he prefers to be called) overviews JSON-P. He discusses the basics of JSON, JSON-P, the DOM-like Object Model API and the StAX-like Streaming API. There's also the 20-minute JSON-P presentation on the GlassFish videos YouTube channel and my own slide deck below:

You can also check out the very well written JSON-P section of the official Java EE 7 Tutorial or try things out with the newly released Java EE 7 SDK.