Igor Polevoy
Igor Polevoy

Created Apr 19 2023

The release 3.0 is a cornerstone release, because it is the first official release post-Java 11, and is built for Java 16. Many features that were added to the project, were added to this release and were not ported to previous releases for Java 8 and Java 11. Since this release took so long, it will be followed by a new release 3.1 for Java 17 LTS almost unchanged.

Convenience working with JSON

As the Internet development pretty much standardized on JSON as the linqua-franqa of the Internet, JavaLite added a number of conveniences working with JSON, be it reading, writing, validating many other features.

JSONMap class gets a new constructor

Here is a new constructor for the class JSONMap

It allows writing one-liners to create map objects that are JSON-enabled:

see more: Implement a convenience constructor

JSONHelper gets a new method jsonString(...)

for example, a call:

will generate a string:

{"first_name": "Marilyn","last_name": "Monroe"}

Convenience JSON methods for controllers

If your controller expects a JSON request that can be converted to a map, you can convert the request into a map using the method: getRequestJSONMap():

A corresponding getRequestJSONList() was also added.


Responding with JSON from controllers also got easier:

The method respondJSON(obj) will try to convert any object to a JSON string and will also set the Content-type header to application/json.

Controller Spec conveniences

The same convenience is also available for sending JSON documents from controller tests:

Note, that the method json(..) accepts a String and automatically sets the application/json content type.

Additionally, two more methods were added to the controller specs that help parse controller output: responseJSONMap() and responseJSONList(). here is a whole spec example:

These methods make controller specs easier to write and to read.

JavaLite HTTP Client

This library also benefited from the added JSON support:

Of course, watch out for a runtime exception in case the output is not JSON.

Implementation of WebSockets

Documentation coming soon.

In the meantime, you can review the latest Release Notes: