tracks/csharp/generators/Input/CanonicalDataCasesJsonConverter.cs in trackler-2.2.1.27 vs tracks/csharp/generators/Input/CanonicalDataCasesJsonConverter.cs in trackler-2.2.1.28
- old
+ new
@@ -1,25 +1,17 @@
using System;
-using System.Collections.Generic;
using System.Reflection;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Generators.Input
{
public class CanonicalDataCasesJsonConverter : JsonConverter
{
- private const string TokensPath = "$..*[?(@.property)]";
+ public override bool CanConvert(Type objectType) => typeof(CanonicalDataCase[]).GetTypeInfo().IsAssignableFrom(objectType);
- public override bool CanConvert(Type objectType) => typeof(IEnumerable<CanonicalData>).GetTypeInfo().IsAssignableFrom(objectType);
-
- public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
- {
- var casesToken = JToken.ReadFrom(reader);
- var caseTokens = new JArray(casesToken.SelectTokens(TokensPath));
-
- return new JArray(caseTokens).ToObject(objectType);
- }
+ public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ => CanonicalDataCasesJson.ToArray(JToken.ReadFrom(reader));
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotImplementedException();
}
}
\ No newline at end of file