Class JsonFileFormat<T>

  • Type Parameters:
    T - type of items a source using this file format will emit
    All Implemented Interfaces:
    FileFormat<T>, java.io.Serializable

    public class JsonFileFormat<T>
    extends java.lang.Object
    implements FileFormat<T>
    FileFormat for the JSON Lines files. See FileFormat.json() for more details.
    Since:
    Jet 4.4
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String FORMAT_JSON
      Format ID for JSON.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Class<T> clazz()
      Returns the class Jet will deserialize data into.
      boolean equals​(java.lang.Object o)  
      java.lang.String format()
      Returns the name of the file format.
      int hashCode()  
      boolean isMultiline()
      Specifies if the Json parser should accept json records spanning multiple lines.
      JsonFileFormat<T> multiline​(boolean multiline)
      Specifies if the Json parser should accept json records spanning multiple lines.
      JsonFileFormat<T> withClass​(java.lang.Class<T> clazz)
      Specifies class that data will be deserialized into.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • FORMAT_JSON

        public static final java.lang.String FORMAT_JSON
        Format ID for JSON.
        See Also:
        Constant Field Values
    • Method Detail

      • withClass

        @Nonnull
        public JsonFileFormat<T> withClass​(@Nullable
                                           java.lang.Class<T> clazz)
        Specifies class that data will be deserialized into. If parameter is null data is deserialized into Map<String, Object>.
        Parameters:
        clazz - type of the object to deserialize JSON into
      • multiline

        @Nonnull
        public JsonFileFormat<T> multiline​(boolean multiline)
        Specifies if the Json parser should accept json records spanning multiple lines.

        The parser handles JSON records spanning multiple lines by default, but it prevents reading the file in parallel when using the Hadoop based connector, because the file is split at arbitrary positions.

        Set this to false when reading large JSON files using Hadoop connector. Each line in the file must contain exactly one JSON record.

        This setting has no effect when Hadoop is not used.

        Parameters:
        multiline - true, if the JSON parser should accept records spanning multiple lines, defaults to true
      • clazz

        @Nullable
        public java.lang.Class<T> clazz()
        Returns the class Jet will deserialize data into. Null if not set.
      • isMultiline

        public boolean isMultiline()
        Specifies if the Json parser should accept json records spanning multiple lines.
      • format

        @Nonnull
        public java.lang.String format()
        Description copied from interface: FileFormat
        Returns the name of the file format. The convention is to use the well-known filename suffix or, if there is none, a short-form name of the format.
        Specified by:
        format in interface FileFormat<T>
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object