Class KiotaJsonSerialization

java.lang.Object
com.microsoft.kiota.serialization.KiotaJsonSerialization

public class KiotaJsonSerialization extends Object
Helper methods for JSON serialization of kiota models
  • Method Details

    • serializeAsStream

      @Nonnull public static <T extends Parsable> InputStream serializeAsStream(@Nonnull T value) throws IOException
      Serializes the given value to a stream
      Type Parameters:
      T - the type of the value to serialize
      Parameters:
      value - the value to serialize
      Returns:
      the serialized value as a stream
      Throws:
      IOException - when the stream cannot be closed or read.
    • serializeAsStream

      @Nonnull public static <T extends Parsable> InputStream serializeAsStream(@Nonnull T value, boolean serializeOnlyChangedValues) throws IOException
      Serializes the given value to a stream
      Type Parameters:
      T - the type of the value to serialize
      Parameters:
      value - the value to serialize
      serializeOnlyChangedValues - whether to serialize all values in value if value is a BackedModel
      Returns:
      the serialized value as a stream
      Throws:
      IOException - when the stream cannot be closed or read.
    • serializeAsString

      @Nonnull public static <T extends Parsable> String serializeAsString(@Nonnull T value) throws IOException
      Serializes the given value to a string
      Type Parameters:
      T - the type of the value to serialize
      Parameters:
      value - the value to serialize
      Returns:
      the serialized value as a string
      Throws:
      IOException - when the stream cannot be closed or read.
    • serializeAsString

      @Nonnull public static <T extends Parsable> String serializeAsString(@Nonnull T value, boolean serializeOnlyChangedValues) throws IOException
      Serializes the given value to a string
      Type Parameters:
      T - the type of the value to serialize
      Parameters:
      value - the value to serialize
      serializeOnlyChangedValues - whether to serialize all values in value if value is a BackedModel
      Returns:
      the serialized value as a string
      Throws:
      IOException - when the stream cannot be closed or read.
    • serializeAsStream

      @Nonnull public static <T extends Parsable> InputStream serializeAsStream(@Nonnull Iterable<T> values) throws IOException
      Serializes the given value to a stream
      Type Parameters:
      T - the type of the value to serialize
      Parameters:
      values - the values to serialize
      Returns:
      the serialized value as a stream
      Throws:
      IOException - when the stream cannot be closed or read.
    • serializeAsStream

      @Nonnull public static <T extends Parsable> InputStream serializeAsStream(@Nonnull Iterable<T> values, boolean serializeOnlyChangedValues) throws IOException
      Serializes the given value to a stream
      Type Parameters:
      T - the type of the value to serialize
      Parameters:
      values - the values to serialize
      serializeOnlyChangedValues - whether to serialize all values in value if value is a BackedModel
      Returns:
      the serialized value as a stream
      Throws:
      IOException - when the stream cannot be closed or read.
    • serializeAsString

      @Nonnull public static <T extends Parsable> String serializeAsString(@Nonnull Iterable<T> values) throws IOException
      Serializes the given value to a string
      Type Parameters:
      T - the type of the value to serialize
      Parameters:
      values - the values to serialize
      Returns:
      the serialized value as a string
      Throws:
      IOException - when the stream cannot be closed or read.
    • serializeAsString

      @Nonnull public static <T extends Parsable> String serializeAsString(@Nonnull Iterable<T> values, boolean serializeOnlyChangedValues) throws IOException
      Serializes the given value to a string
      Type Parameters:
      T - the type of the value to serialize
      Parameters:
      values - the values to serialize
      serializeOnlyChangedValues - whether to serialize all values in value if value is a BackedModel
      Returns:
      the serialized value as a string
      Throws:
      IOException - when the stream cannot be closed or read.
    • deserialize

      @Nonnull public static <T extends Parsable> T deserialize(@Nonnull InputStream stream, @Nonnull ParsableFactory<T> parsableFactory)
      Deserializes the given stream to a model object
      Type Parameters:
      T - the type of the value to deserialize
      Parameters:
      stream - the stream to deserialize
      parsableFactory - the factory to use for creating the model object
      Returns:
      the deserialized value
    • deserialize

      @Nonnull public static <T extends Parsable> T deserialize(@Nonnull String value, @Nonnull ParsableFactory<T> parsableFactory) throws IOException
      Deserializes the given string to a model object
      Type Parameters:
      T - the type of the value to deserialize
      Parameters:
      value - the string to deserialize
      parsableFactory - the factory to use for creating the model object
      Returns:
      the deserialized value
      Throws:
      IOException - when the stream cannot be closed or read.
    • deserializeCollection

      @Nonnull public static <T extends Parsable> List<T> deserializeCollection(@Nonnull String value, @Nonnull ParsableFactory<T> parsableFactory) throws IOException
      Deserializes the given string to a collection of model objects
      Type Parameters:
      T - the type of the value to deserialize
      Parameters:
      value - the string to deserialize
      parsableFactory - the factory to use for creating the model object
      Returns:
      the deserialized value
      Throws:
      IOException - when the stream cannot be closed or read.
    • deserializeCollection

      @Nonnull public static <T extends Parsable> List<T> deserializeCollection(@Nonnull InputStream stream, @Nonnull ParsableFactory<T> parsableFactory)
      Deserializes the given stream to a collection of model objects
      Type Parameters:
      T - the type of the value to deserialize
      Parameters:
      stream - the stream to deserialize
      parsableFactory - the factory to use for creating the model object
      Returns:
      the deserialized value