GSON array

GSON build array with newlines

GSON build array with newlinesGSON array

JSON has become a famous data format for exchanging information over the Internet. It is commonly used in REST API and for storing loosely structured data. Compared to XML, it is concise, and unfortunately, less human readable. Beautifiers and pretty printers can easily enhance this. I will show you the different options available in GSON to convert an array of objects to a JSON string.

HashSet for a few elements

Is it worth using HashSet for a few elements?

Is it worth using HashSet for a few elements?loadData

HashSets are known from its efficiency, when it comes to checking, if they contain a particular object. They were designed exactly for doing that in a constant time. Contrary, checking objects existence in an ArrayList has a linear computational complexity, which is less efficient in theory. But is it true for small sets as well?

Caffeine cache

Cache in Spring Boot 3 application

Generate SQL script from Liquibase changelog fileupgrade SQL script

Adding cache to a Spring Boot 3 application is very quick and easy. It is a matter of choosing one of a few supported cache managers and putting relevant annotations to proper places in the code. Caffeine cache is one of the options.

 

large file in REST

Large files in REST API

Besides exchanging JSON objects in a request or a response body, REST API can also use files. Doing so is not a big deal when the files are small. Things get a little bit more complicated when we have to respond with a big file. No one wants to keep in memory a few hundred megabytes of data waiting on the client to slowly download it. It must be streamed.

 

send file via REST

Send file with REST API

Besides working on JSON objects, Spring Boot application can also make files available for downloading via REST API. We can build an application that exposes endpoints that can be used to download raw files, images, CSV files etc. We are not only limited to well-defined objects serialized to a JSON format. See how to do that.

 

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.