How to get the JsonFactory settings using Jackson in Java?


The JsonFactory class is a thread-safe and responsible for creating instances of writer and reader. The list of settings that can be turned on/off is present in an enumeration JsonFactory.Feature, it contains static method values() that return the enum constant of this type with the specified name.

Syntax

public static enum JsonFactory.Feature extends Enum<JsonFactory.Feature>

Example

import com.fasterxml.jackson.core.JsonFactory;
public class JsonFactorySettingsTest {
   public static void main(String[] args) {
      JsonFactory jsonFactory = new JsonFactory();
      for(JsonFactory.Feature feature : JsonFactory.Feature.values()) {
         boolean result = jsonFactory.isEnabled(feature);
         System.out.println(feature.name() + ":" + result);
      }
   }
}

Output

INTERN_FIELD_NAMES:true
CANONICALIZE_FIELD_NAMES:true
FAIL_ON_SYMBOL_HASH_OVERFLOW:true
USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING:true

raja
raja

e

Updated on: 07-Jul-2020

617 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements