1
下面是我的代碼,這給JSON數據,要從必需的JSON格式列表中獲取數據
for (int k = 0; k < 4; k++)
{
List<HMData> Data_Content = new List<HMData>();
for (int l = 0; l < 7; l++)
{
Value_LfromList = LValues.ElementAt((k * 7) + l);
Value_IfromList = IValues.ElementAt((k * 7) + l);
Value_BfromList = BValues.ElementAt((k * 7) + l);
Data_Content.Add(new HMData { x = Value_LfromList, y = Value_IfromList, z = Value_BfromList });
}
data_list.Add(Data_Content);
}
var data = new{data=data_list};
var series = new []{ data};
var obj = new { chart, series };
string result = jSearializer.Serialize(obj);
輸出我得到的是如下,
{
"chart":{"type":"bubble"},
"series":
[
{"data":
[
[
{"x":7,"y":7,"z":49},{"x":7,"y":7,"z":49},{"x":7,"y":9,"z":63},
{"x":5,"y":9,"z":45},{"x":4,"y":3,"z":12},{"x":2,"y":6,"z":12},
{"x":3,"y":5,"z":15}
],
[
{"x":7,"y":8,"z":56},{"x":7,"y":8,"z":56},{"x":7,"y":8,"z":56},
{"x":9,"y":6,"z":54},{"x":5,"y":7,"z":35},{"x":3,"y":8,"z":24},
{"x":4,"y":3,"z":12}
],
[
{"x":7,"y":8,"z":56},{"x":7,"y":8,"z":56},{"x":7,"y":8,"z":56},
{"x":8,"y":7,"z":56},{"x":5,"y":7,"z":35},{"x":3,"y":7,"z":21},
{"x":5,"y":8,"z":40}
],
[
{"x":3,"y":7,"z":21},{"x":3,"y":7,"z":21},{"x":5,"y":2,"z":10},
{"x":5,"y":2,"z":10},{"x":8,"y":6,"z":48},{"x":7,"y":3,"z":21},
{"x":6,"y":7,"z":42}
]
]
}
]
}
但我想數據如下所示,
{
"chart":{"type":"bubble"},
"series":
[
{"data":[{"x":7,"y":7,"z":49},{"x":7,"y":7,"z":49},{"x":7,"y":9,"z":63},{"x":5,"y":9,"z":45},{"x":4,"y":3,"z":12},{"x":2,"y":6,"z":12},{"x":3,"y":5,"z":15}]},
{"data":[{"x":7,"y":8,"z":56},{"x":7,"y":8,"z":56},{"x":7,"y":8,"z":56},{"x":9,"y":6,"z":54},{"x":5,"y":7,"z":35},{"x":3,"y":8,"z":24},{"x":4,"y":3,"z":12}]},
{"data":[{"x":7,"y":8,"z":56},{"x":7,"y":8,"z":56},{"x":7,"y":8,"z":56},{"x":8,"y":7,"z":56},{"x":5,"y":7,"z":35},{"x":3,"y":7,"z":21},{"x":5,"y":8,"z":40}]},
{"data":[{"x":3,"y":7,"z":21},{"x":3,"y":7,"z":21},{"x":5,"y":2,"z":10},{"x":5,"y":2,"z":10},{"x":8,"y":6,"z":48},{"x":7,"y":3,"z":21},{"x":6,"y":7,"z":42}]}
]
}
總之,我的4個數據對象獲取存儲在一個數據串,我想有不同的數據串......任何想法浩W I可以做到這一點,
非常感謝...ü再次保存me..Thanks很多... – Reshma