Gson – How to convert Java object to / from JSON
In this tutorial, we will show you how to use Gson to convert Java object to / from JSON. The toJson() – Convert Java objects to JSON and fromJson() –…
Favourite tutorials for developers
Core Java is the fundamental form of Java. We use it in all Java platforms and technologies. Without going through core Java, it is impossible to advance to advanced Java. Unlike core Java, advanced Java is a specialization of the core Java in some particular domain, such as database handling, networking, and the web.
In this tutorial, we will show you how to use Gson to convert Java object to / from JSON. The toJson() – Convert Java objects to JSON and fromJson() –…
In this tutorial, we will show you how to enable JSON pretty print in Gson framework. By default, Gson compact-print the JSON output, To enable JSON pretty-print, create Gson object…
In Jackson, we can use writerWithDefaultPrettyPrinter() to pretty print the JSON output. Tested with Jackson 2.9.8 1. Pretty Print JSON 1.1 By default, Jackson print in compact format: Output 1.2…
This Jackson tutorial show you how to use JsonGenerator to write JSON string and JSON array into a file, furthermore, read it with JsonParser. Jackson Streaming APIs: JsonGenerator – Write…
Gson provide simple toJson() and fromJson() methods to convert Java objects to / from JSON. The toJson() – Java object to JSON and fromJson() – JSON to Java object
In Jackson, we can use Tree Model to represent the JSON structure, and perform the CRUD operations via JsonNode, similar to the XML DOM tree. This Jackson Tree Model is…
In Jackson, we can use mapper.readValue(json, Map.class) to convert a JSON string to a Map
Few Jackson examples to convert a JSON array string to a List.
In Jackson, we can use @JsonView to limit or control fields display for different users. Puts @JsonView on field level to limit fields display for different views. Below example, show…
In Jackson, we can use @JsonInclude(JsonInclude.Include.NON_NULL) to ignore the null fields. To ignore the null fields, put @JsonInclude on class level or field level. Alternatively, we also can configure to…