62,047
社区成员
发帖
与我相关
我的任务
分享
{
"IPAuthority":1,
"101":{"data1":
[['2019-8-14 8:00:00', 1], ['2019-8-14 8:10:00', 3], ['2019-8-14 8:20:00', 5], ['2019-8-14 8:30:00', 6], ['2019-8-14 8:40:00', 66],['2019-8-14 8:50:00', 8], ['2019-8-14 9:00:00',11], ['2019-8-14 9:20:00', 32], ['2019-8-14 9:30:00', 54]],
"data2":
[['2019-8-14 8:00:00', 1], ['2019-8-14 8:10:00', 3], ['2019-8-14 8:20:00', 5], ['2019-8-14 8:30:00', 6], ['2019-8-14 8:40:00', 66],['2019-8-14 8:50:00', 8], ['2019-8-14 9:00:00',11], ['2019-8-14 9:20:00', 32], ['2019-8-14 9:30:00', 54]]
},
"102":{"data1":
[['2019-8-14 8:00:00', 1], ['2019-8-14 8:10:00', 3], ['2019-8-14 8:20:00', 5], ['2019-8-14 8:30:00', 6], ['2019-8-14 8:40:00', 66],['2019-8-14 8:50:00', 8], ['2019-8-14 9:00:00',11], ['2019-8-14 9:20:00', 32], ['2019-8-14 9:30:00', 54]],
"data2":
[['2019-8-14 8:00:00', 1], ['2019-8-14 8:10:00', 3], ['2019-8-14 8:20:00', 5], ['2019-8-14 8:30:00', 6], ['2019-8-14 8:40:00', 66],['2019-8-14 8:50:00', 8], ['2019-8-14 9:00:00',11], ['2019-8-14 9:20:00', 32], ['2019-8-14 9:30:00', 54]]
}
}
public class Rootobject
{
public int IPAuthority { get; set; }
public _101 data { get; set; }
public _102 data { get; set; }
}
public class data
{
public Dictionary<string, int> data1 { get; set; }
public Dictionary<string, int> data2 { get; set; }
}
{
"IPAuthority":1,
"101":{"data1":
{'2019-8-14 8:00:00', 1, '2019-8-14 8:10:00', 3, '2019-8-14 8:20:00', 5, '2019-8-14 8:30:00', 6, '2019-8-14 8:40:00', 66,'2019-8-14 8:50:00', 8, '2019-8-14 9:00:00',11, '2019-8-14 9:20:00', 32, '2019-8-14 9:30:00', 54},
.......................
}
public class Rootobject
{
public int IPAuthority { get; set; }
//101,102作为key
public Dictionary<string,data> data { get; set; }
}
public class data
{
public List<string> list{get;set;}
}
public class Rootobject
{
public int IPAuthority { get; set; }
public List<List<string>> Data1 { get; set; } = new List<List<string>>();
}
赋值
...实例化类
foreach (DataRow dr in dt.Rows)
{
rootobject.Data1.Add(new List<string> { (dr["rq"].ToString()+ "," +dr["vv"].ToString() });
}
结果变成这样了
{"ipAuthority":1,"data1":[["2020-07-01,1341"],["2020-07-02,1346"],["2020-07-03,1347"],["2020-07-04,1348"]]}
还是不符合要求
public class Rootobject
{
public int IPAuthority { get; set; }
public Dictionary<string,data> DataArray{ get; set; }
}
public class data
{
public Dictionary<string,List<DataValue>> data1 { get; set; }
public Dictionary<string,List<DataValue>> data2 { get; set; }
}
public class DataValue
{
public string DateTime{get;set;}
public int Age{ get; set;}
}