Jackson Custom field name with @JsonProperty
When the JSON field name doesn’t exactly match the Java field names, we can use @JsonProperty to change the name of a JSON field in Jackson. Table of contents: 1. Setup Jackson 2. JSON Unrecognized...
View ArticleJackson Custom Serializer and Deserializer Examples
This article shows how to create a Jackson custom serializer and deserializer to parse JSON data that contains a LocalDate type. The Jackson custom serializer or deserializer is useful when we want to...
View ArticleRead and Write JSON to File using Gson
This article shows how to use Gson to write a Java object to a JSON file and read that JSON file back into a Java object. Table of contents: 1. Download Google Gson 2. A Java Object 3. Write Java...
View ArticleGson custom field name with @SerializedName
When the JSON field name doesn’t exactly match the Java object field names, we can use @SerializedName to change the JSON’s matching field name in Gson. Table of contents: 1. Setup Google Gson 2. JSON...
View ArticleGson supports Java 8 date time types
Gson does not directly support Java 8’s date-time APIs like LocalDate, LocalDateTime, and ZonedDateTime. However, we can create a custom JSON serializer to support Java 8 date-time types. This article...
View ArticleHow to exclude fields in Gson
In GSON, we can use the transient keyword, ExclusionStrategy, and @Expose to exclude fields during the JSON serialization or deserialization process. Table of contents: 1. Setup Google Gson 2. Using...
View ArticlePretty Print JSON with JSON.simple
This article shows how to pretty print JSON with JSON.simple. Table of contents: 1. Setup JSON.simple 2. Default Compact Print JSON 3. Pretty Print JSON with JSON.simple 4. Write Pretty Print JSON to a...
View ArticleHow to traverse all files from a folder in Java
In Java, we can use the Files.walk() API to traverse all files from a folder and its subfolders. Table of contents: 1. Traverse all files from a folder in Java 2. Traverse all files from a folder and...
View Article