Home » Tag Archives: JSON

Tag Archives: JSON

Java: Streaming a JDBC ResultSet as JSON

This post shows how you can convert a java.sql.ResultSet to JSON and stream it back to the caller. This is useful if you want to send a large dataset from a JDBC DataSource to a web application in JSON format. Streaming allows you to transfer the data, little by little, without having to load it all into the server’s memory. ...

Read More »

JSON-B Asymmetrical Property Binding

The JSON-B specification defines binding annotations such as @JsonbProperty or @JsonbTransient to declaratively map Java objects to JSON, and back. These annotations can be used ‘asymmetrically’ to define different handling of serialization and deserialization. If JSON Binding annotations are annotated on Java properties, or on both getters and setters, they will control how the objects are serialized and deserialized. If ...

Read More »

Writing Big JSON Files With Jackson

Sometimes you need to export a lot of data to JSON to a file. Maybe it’s “export all data to JSON”, or the GDPR “Right to portability”, where you effectively need to do the same. And as with any big dataset, you can’t just fit it all in memory and write it to a file. It takes a while, it ...

Read More »

Get to Know Custom De/Serializers: JSON Binding Overview Series

The most advanced way to customize JSON Binding is with custom serializers and deserializers. JSON-B serializers and deserializers are the lowest level of customisation available and give access to the JSON Processing parsers and generators. A custom serializer must implement the JsonbSerializer interface and provide logic for the serialise() method. This code shows a simple example of how to customise ...

Read More »

Get to Know Adapters: JSON Binding Overview Series

An adapter configures custom object creation and serialization by implementing the JsonbAdapter interface. The methods adaptToJson() and adaptFromJson() are overwritten with logic that performs the serialization and deserialization operation. The next article is about the most advanced way to customize JSON-B with custom serializers and deserializers. In the example implementation here, the adaptToJson() method has been implemented with code that ...

Read More »

Get to Know Custom Object Creation: JSON Binding Overview Series

Let’s take a look at how JSON Binding handles custom object creation. Next article in this series covers customization of JSON-B with adapters. JSON-B expects all classes to have a public no-argument constructor, which it uses during deserialization to instantiate the target class. Once the instance is created, it is populated with data from the JSON document by calling the appropriate ...

Read More »

Get to Know Customisation: JSON Binding Overview Series

Let’s take a look at how the annotation model and runtime configuration work when customizing the JSON Binding serialization and deserialization processes. Next article in this series covers how JSON-B handles custom object creation. Annotation Method Using the annotation method, it’s possible to customize the default serialization and deserialization behavior by annotating fields, JavaBean methods, and classes. @JsonbNillable @JsonbPropertyOrder(PropertyOrderStrategy.REVERSE) public class ...

Read More »

Get to Know JSON Binding: Overview Series

The Java API for JSON Binding (JSON-B) 1.0 strengthens the Java EE platform’s overall support for the JSON data interchange format. Already, the Java API for JSON Processing (JSON-P) 1.1 has proved popular and together they form the perfect partners that fill a long-standing shortcoming in Java EE’s JSON capacity. Next article in this series covers the customization of JSON ...

Read More »