Class JacksonHelper

java.lang.Object
util.JacksonHelper

public class JacksonHelper extends Object
Helper class for reading and writing a list of objects to JSON.
  • Constructor Details

    • JacksonHelper

      public JacksonHelper()
  • Method Details

    • readList

      public static <T> List<T> readList(InputStream in, Class<T> elementClass) throws IOException
      Deserializes a list of objects from JSON.
      Type Parameters:
      T - the type of the list elements
      Parameters:
      in - the input stream from which JSON data will be read
      elementClass - represents the class of the elements
      Returns:
      the list of objects deserialized from JSON
      Throws:
      IOException - if any I/O error occurs
    • writeList

      public static <T> void writeList(OutputStream out, List<T> list) throws IOException
      Serializes a list of objects to JSON.
      Type Parameters:
      T - the type of the list elements
      Parameters:
      out - the output stream to which JSON data will be written
      list - the list of objects to be serialized
      Throws:
      IOException - if any I/O error occurs