【发布时间】:2019-01-20 07:09:58
【问题描述】:
我有一个按 user_id 分组的List<List<JsonCategoryInfo>>。
public class JSONCategoryInfo
{
public int user_id {get; set;}
public string name {get; set;}
public int category_id {get; set;}
public string category {get; set;}
public int info_id {get; set;}
public string info_key{get; set;}
public string info_value{get; set;}
}
我正在尝试将其转换为List<List<JSONFullChildInfo>>
public class JSONFullChildInfo
{
public JSONFullChildInfo()
{
categoriesAndInfo = new List<CategoriesAndInfo>();
}
public int user_id {get; set;}
public string name {get; set;}
public IList<CategoriesAndInfo> categoriesAndInfo {get; set;}
}
public class CategoriesAndInfo
{
public CategoriesAndInfo()
{
info = new List<JSONChildInfo>();
}
public string category {get; set;}
public int category_id {get; set;}
public IList<JSONChildInfo> info {get; set;}
}
public class JSONChildInfo
{
public int info_id {get; set;}
public string info_key{get; set;}
public string info_value{get; set;}
}
我能够做到这一点的唯一方法是使用大量嵌套循环和大量可能不必要的编码行。想知道是否有有效的方法来做到这一点?
【问题讨论】:
-
欢迎来到stackoverflow。请花一分钟时间拨打tour,尤其是How to Ask。就像现在一样,你的问题太宽泛了,不适合在这里。此外,我们需要看看您已经尝试过什么。