Class ConfigDeserializer

java.lang.Object
org.apache.tika.config.ConfigDeserializer

public class ConfigDeserializer extends Object
Deserializes JSON configuration without a compile-time dependency on Jackson.

Reads through tika-serialization (see ConfigReader), which also refuses untrusted JSON that sets an OperatorOnly property. Throws if tika-serialization is not available.

Usage pattern in parsers, detectors, and other Tika components:

 public class MyParser implements Parser {
     public static class Config {
         public int timeout = 30;
         public boolean verbose = false;
     }

     public MyParser() {
         // Default constructor for SPI
     }

     public MyParser(Config config) {
         // Constructor with explicit config object
         this.timeout = config.timeout;
         this.verbose = config.verbose;
     }

     public MyParser(JsonConfig jsonConfig) {
         this(ConfigDeserializer.buildConfig(jsonConfig, Config.class));
     }
 }
 
Since:
Apache Tika 4.0
  • Constructor Details

    • ConfigDeserializer

      public ConfigDeserializer()
  • Method Details

    • buildConfig

      public static <T> T buildConfig(JsonConfig jsonConfig, Class<T> configClass)
      Deserializes a JSON configuration to a configuration object. Untrusted JSON (see JsonConfig.trusted()) may not set an OperatorOnly property.
      Type Parameters:
      T - the configuration type
      Parameters:
      jsonConfig - the JSON configuration
      configClass - the configuration class
      Returns:
      the deserialized configuration object
      Throws:
      RuntimeException - if tika-serialization is not on the classpath, deserialization fails, or untrusted JSON sets an operator-only property