Class JsonMetadata

java.lang.Object
org.apache.tika.serialization.JsonMetadata

public class JsonMetadata extends Object
  • Constructor Details

    • JsonMetadata

      public JsonMetadata()
  • Method Details

    • setStreamReadConstraints

      public static void setStreamReadConstraints(com.fasterxml.jackson.core.StreamReadConstraints constraints)
      Sets the stream read constraints for JSON parsing of metadata. This affects all subsequent calls to fromJson(Reader).

      Typically called by TikaLoader during initialization based on the "metadata-list" configuration section.

      Parameters:
      constraints - the constraints to use
    • setTypedValues

      public static void setTypedValues(boolean typed)
      Opt-in: write values of registered INTEGER, REAL and BOOLEAN keys as JSON numbers and booleans, and of JSON keys (e.g. tk:chunks) as JSON rather than an escaped string. Off by default for backwards compatibility. fromJson(Reader) reads either form.

      Typically called by TikaLoader from the "metadata-list" configuration section.

    • isTypedValues

      public static boolean isTypedValues()
    • getStreamReadConstraints

      public static com.fasterxml.jackson.core.StreamReadConstraints getStreamReadConstraints()
      Gets the current stream read constraints.
      Returns:
      the current constraints
    • toJson

      public static void toJson(Metadata metadata, Writer writer) throws IOException
      Serializes a Metadata object to Json. This does not flush or close the writer.
      Parameters:
      metadata - metadata to write
      writer - writer
      Throws:
      IOException - if there is an IOException during writing
    • fromJson

      public static Metadata fromJson(Reader reader) throws IOException
      Read metadata from reader. This does not close the reader.
      Parameters:
      reader - reader to read from
      Returns:
      Metadata or null if reader is null
      Throws:
      IOException - in case of parse failure or IO failure with Reader
    • setPrettyPrinting

      public static void setPrettyPrinting(boolean prettyPrint)