using System.Collections.Generic;
using Newtonsoft.Json.Linq;
public static void Main()
""book_types"": [{""culture"":2},{""stories"":3}]
DataTable dts = JsonConvert.DeserializeObject<DataTable>(json);
var groupedByUserName = (from DataRow dr in dts.Rows
user_name = dr["user_name"].ToString(),
book_types = JArray.FromObject(dr["book_types"])
JObject jObj = new JObject();
jObj.Add("user_name", x.user_name);
foreach (JObject book_type in x.book_types)
jObj.Merge(JObject.FromObject(book_type));
return jObj.ToObject<object>();
var apiResult = new ApiResult
Data = groupedByUserName,
Count = groupedByUserName.Count,
Console.WriteLine(JsonConvert.SerializeObject(apiResult, Formatting.Indented));
public List<dynamic> Data { get; set; }
public int Count { get; set; }
public bool Success { get; set; }