mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-25 15:08:37 +02:00
50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
using System;
|
|
using System.IO;
|
|
using ProtoBuf;
|
|
using ServiceStack.Text;
|
|
|
|
namespace MediaBrowser.ApiInteraction
|
|
{
|
|
public static class DataSerializer
|
|
{
|
|
public static T DeserializeJsonFromStream<T>(Stream stream)
|
|
{
|
|
return JsonSerializer.DeserializeFromStream<T>(stream);
|
|
}
|
|
|
|
public static T DeserializeJsvFromStream<T>(Stream stream)
|
|
{
|
|
return TypeSerializer.DeserializeFromStream<T>(stream);
|
|
}
|
|
|
|
public static object DeserializeJsvFromStream(Stream stream, Type type)
|
|
{
|
|
return TypeSerializer.DeserializeFromStream(type, stream);
|
|
}
|
|
|
|
public static object DeserializeJsonFromStream(Stream stream, Type type)
|
|
{
|
|
return JsonSerializer.DeserializeFromStream(type, stream);
|
|
}
|
|
|
|
public static T DeserializeProtobufFromStream<T>(Stream stream)
|
|
{
|
|
return Serializer.Deserialize<T>(stream);
|
|
}
|
|
|
|
public static void Configure()
|
|
{
|
|
JsConfig.DateHandler = ServiceStack.Text.JsonDateHandler.ISO8601;
|
|
JsConfig.ExcludeTypeInfo = true;
|
|
JsConfig.IncludeNullValues = false;
|
|
}
|
|
}
|
|
|
|
public enum SerializationFormat
|
|
{
|
|
Json,
|
|
Jsv,
|
|
Protobuf
|
|
}
|
|
}
|