CSharp · Console
using System;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
public class Program
{
public class SourceGuardFinding
{
[JsonProperty("disabled-protections")]
public JArray DisabledProtections { set => IsPartialResult = value != null && value.HasValues; }
public bool IsPartialResult { get; private set; }
}
public static void Main()
{
var v = JObject.Parse(@"{ ""disabled-protections"": [] }");
v = JObject.Parse(@"{ ""disabled-protections"": [1] }");
var ser = JsonConvert.SerializeObject(v);
var findingsList = JsonConvert.DeserializeObject<SourceGuardFinding>(ser);
Console.WriteLine($"b: {findingsList.IsPartialResult}");
Console.WriteLine($"ser: {JsonConvert.SerializeObject(findingsList)}");
Console.WriteLine();
}
}