我正在关注json数据:
[
{
"Data": [
[915408000000,1.1789],
[915494400000,1.179]
]
}
]
但我不想要属性名称“Data”,我想要这个:
[
[915408000000,1.1789],
[915494400000,1.179]
]
制作上述json数据的代码:
var myJsonObList = new List<MyCurrencyJsonBuilder>();
var list = // I am getting data from sqlServer in a list;
var myJsonObj = new MyCurrencyJsonBuilder(list);
myJsonObList.Add(myJsonObj);
//send response with json
context.Response.Write(JsonConvert.SerializeObject(myJsonObList));
类别:
class MyCurrencyJsonBuilder
{
List<List<dynamic>> _data { get; set; }
public MyCurrencyJsonBuilder(List<List<dynamic>> currencydata)
{
this._data = currencydata;
}
public List<List<dynamic>> Data
{
get { return _data; }
}
}
答案 0 :(得分:0)
var json = @"
[
{
""Data"": [
[915408000000, 1.1789],
[915494400000,1.179]
]
}
]";
var jToken = JsonConvert.DeserializeObject<JToken>(json);
var jArray = new JArray();
foreach (var token in jToken)
{
jArray.Add(token["Data"].Children());
}
var responseJson = JsonConvert.SerializeObject(jArray);
// responseJson = [[915408000000,1.1789],[915494400000,1.179]]