Thursday Jun 11, 2015

JSON-P 1.1 (JSR 374) update: JSON Merge Patch

JSON Merge Patch (RFC 7386) is relatvely new standard in the JSON space. It defines a set of modifications that will be used to transform a target resource; those modifcations are themselves defined in a JSON object. JSON Merge Patch is a very simple standard with a few limitations but it seems to be useful enough. So and in addition to JSON Pointer (RFC  6901) and JSON Patch (RFC 6902), the JSR374 Experts Group has recently decided to adding JSON Merge Patch support to the JSON-P 1.1 API might be useful. You can track the initial works around JSON merge Patch here.

As usual, feedback is always welcome. And to easily get started with JSON-P 1.1, you should watch the recording of the Adopt-a-JSR session that was held recently with Kin-man Chung (JSR 374 Spec Lead). It gives all the required technical details but also set some expectations in terms of the type of feedback that the EG is looking for.


Thursday Apr 16, 2015

JSON-P 1.1 (JSR 374) update: JSON Pointer & JSON Patch

'Java API for JSON Processing 1.0' also known as JSON-P (JSR 353) is the standard JSON Processing API that was added in Java EE 7.  JSON-P will be updated and that update (JSON-P 1.1 - JSR 374) should be included in Java EE 8. One of the goals of that revision is to add support for 2 JSON standards namely JSON Patch and JSON Pointer.

By nature JSON is simple and most of the standards in that space are simple as well. JSON Pointer and JSON Patch are 2 IETF RFCs that are closely related. JSON Pointer defines string syntax for identifying a specific value within a JSON document while JSON Patch defines a set (one or more) of operations to apply to a target JSON document. JSON Patch is leveraging JSON Pointer to specify where operation(s) need to be performed in the target JSON document. And a JSON Patch is in itself a JSON document. The most common pattern will be to apply a JSON Patch to transform a JSON document but it will also be possible to obtain a JSON Patch by comparing 2 JSON documents, the returned JSON Patch will then be a 'diff' between the 2 JSON documents.

It is the early day of JSR 374 but the EG is certainly making progress. At this stage, it is already possible to test, amongst other new features, JSON Pointer and JSON Patch as the early build of the JSR 374 RI already support those. Those tests would be a good place to look to understand how the API works. Note that at time of writing, the 'diff' method isn't yet implemented in the early JSR 374 RI build.

Getting feedback early on is really important for the various EGs!  Make sure to look and test the various APIs that will, at some point, be part of Java EE 8.

If you want to know more about the JSON-P 1.1, watch this JavaOne session where Kinman Chung (JSR 374 Specification Lead) explains the plans for JSON-P 1.1. In addition, the Java API for JSON Processing project page, the JSR 374 Users mailing list and Issue Tracker are useful resources to check.

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.