Class KiotaJsonSerialization
java.lang.Object
com.microsoft.kiota.serialization.KiotaJsonSerialization
Helper methods for JSON serialization of kiota models
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Parsable>
Tdeserialize(InputStream stream, ParsableFactory<T> parsableFactory) Deserializes the given stream to a model objectstatic <T extends Parsable>
Tdeserialize(String value, ParsableFactory<T> parsableFactory) Deserializes the given string to a model objectdeserializeCollection(InputStream stream, ParsableFactory<T> parsableFactory) Deserializes the given stream to a collection of model objectsdeserializeCollection(String value, ParsableFactory<T> parsableFactory) Deserializes the given string to a collection of model objectsstatic <T extends Parsable>
InputStreamserializeAsStream(Iterable<T> values) Serializes the given value to a streamstatic <T extends Parsable>
InputStreamserializeAsStream(Iterable<T> values, boolean serializeOnlyChangedValues) Serializes the given value to a streamstatic <T extends Parsable>
InputStreamserializeAsStream(T value) Serializes the given value to a streamstatic <T extends Parsable>
InputStreamserializeAsStream(T value, boolean serializeOnlyChangedValues) Serializes the given value to a streamserializeAsString(Iterable<T> values) Serializes the given value to a stringserializeAsString(Iterable<T> values, boolean serializeOnlyChangedValues) Serializes the given value to a stringserializeAsString(T value) Serializes the given value to a stringserializeAsString(T value, boolean serializeOnlyChangedValues) Serializes the given value to a string
-
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 serializeserializeOnlyChangedValues- 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 serializeserializeOnlyChangedValues- 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 serializeserializeOnlyChangedValues- 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 serializeserializeOnlyChangedValues- 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 deserializeparsableFactory- 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 deserializeparsableFactory- 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 deserializeparsableFactory- 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 deserializeparsableFactory- the factory to use for creating the model object- Returns:
- the deserialized value
-