在没有属性名称

时间:2016-03-10 13:31:01

标签: c#

我正在关注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; }
            }

        }

1 个答案:

答案 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]]