using System.Collections.Generic;
using Newtonsoft.Json.Linq;
public static void Main()
""summary"": ""I need access to blah"",
""self"": ""fake.url.com"",
""value"": ""I need this""
""self"": ""fake.url2.com"",
""value"": ""I need this also""
""summary"": ""Example number 2"",
""self"": ""fake.url3.com"",
""self"": ""fake.url4.com"",
""value"": ""And this too""
var columnPathMappings = new Dictionary<string, string>
{ "summary", "fields.summary" },
{ "customfield_18302", "fields.customfield_18302[*].value" },
string csv = JArray.Parse(json).Cast<JObject>().ToCsv(columnPathMappings);
public static class JsonHelper
public static string ToCsv(this IEnumerable<JObject> items, Dictionary<string, string> columnPathMappings)
if (items == null || columnPathMappings == null)
throw new ArgumentNullException();
var rows = new List<string>();
rows.Add(columnPathMappings.Keys.ToCsv());
foreach (JObject item in items)
rows.Add(columnPathMappings.Values.Select(path => item.SelectTokens(path)).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 =>
if (v is IEnumerable<JToken> e)
v = string.Join(Environment.NewLine, e.Select(t => t.ToString()));
return string.Concat(quote, v.ToString().Replace(quote, doubleQuote), quote);