using System.Collections.Generic;
using Newtonsoft.Json.Linq;
public static void Main()
""property-two"": ""2020-12-10"",
""property-three"": ""D"",
""property-two"": ""2020-12-10"",
""property-three"": ""D"",
var obj = JObject.Parse(json);
var csv = obj.SelectTokens("..attributes").Cast<JObject>().ToCsv();
public static class JsonHelper
public static string ToCsv(this IEnumerable<JObject> items, bool includeHeaders = true)
if (!items.Any()) return string.Empty;
var rows = new List<string>();
rows.Add(items.First().Properties().Select(p => p.Name).ToCsv());
rows.AddRange(items.Select(jo => jo.Properties().Select(p => p.Value.Type == JTokenType.Null ? null : p.Value).ToCsv()));
return string.Join(Environment.NewLine, rows);
public static string ToCsv(this IEnumerable<object> values)
const string quote = "\"";
const string doubleQuote = "\"\"";
return string.Join(",", values.Select(v => v != null ? string.Concat(quote, v.ToString().Replace(quote, doubleQuote), quote) : string.Empty));