How to get the JsonFactory settings using Jackson in Java?

JavaJSONObject Oriented ProgrammingProgramming

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
Published on 24-Oct-2019 12:07:53
Advertisements