Quantcast
Channel: Mkyong.com
Browsing all 28 articles
Browse latest View live

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 Article


Jackson 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 Article


Read 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 Article

Gson 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 Article

Gson 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 Article


How 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 Article

Pretty 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 Article

How 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

Browsing all 28 articles
Browse latest View live