Creating a custom json serializer for PeopleRoles

This commit is contained in:
Zoe Roux
2021-03-08 23:53:46 +01:00
parent b3fdee4bcd
commit d3d2677a83
4 changed files with 27 additions and 5 deletions
+21
View File
@@ -4,6 +4,7 @@ using System.Reflection;
using Kyoo.Models;
using Kyoo.Models.Attributes;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
namespace Kyoo.Controllers
@@ -52,4 +53,24 @@ namespace Kyoo.Controllers
return contract;
}
}
public class PeopleRoleConverter : JsonConverter<PeopleRole>
{
public override void WriteJson(JsonWriter writer, PeopleRole value, JsonSerializer serializer)
{
// TODO this seems to not use the property.ShouldSerialize and cause an recursive inclusion error.
JToken t = JToken.FromObject(value, serializer);
JObject obj = t as JObject;
writer.WriteValue(obj);
}
public override PeopleRole ReadJson(JsonReader reader,
Type objectType,
PeopleRole existingValue,
bool hasExistingValue,
JsonSerializer serializer)
{
throw new NotImplementedException();
}
}
}