我試圖用JSON.Net解析從第三方API返回的結果。如何使用JSON.Net解析此問題?
正如您所看到的,第一個塊似乎是對後續行塊列的描述。我假設這不是標準做法,因爲我無法在任何地方找到對此風格的任何參考。 因爲它不是通常的名稱:值對格式,我有點難住。
{ cols: [{label: "name", type: 'string'},
{label: "caller_id_number", type: 'string'},
{label: "destination_number", type: 'string'},
{label: "call_start", type: 'datetime'},
{label: "duration", type: 'number'},
{label: "bill_seconds", type: 'number'},
{label: "uuid", type: 'string'},
{label: "call_bill_total", type: 'number'},
{label: "recorded", type: 'boolean'}],
rows: [
{c:[{v: "mydomain.com"},
{v: "1650"},
{v: "01902321654"},
{v: new Date(2011, 6, 19, 14, 12, 25)},
{v: 3},
{v: 0},
{v: "07752f6c-b203-11e0-92e6-495a2db86d6d"},
{v: 0},
{v: true}]}
,{c:[{v: "mydomain.com"},{v: "1652"},{v: "034534514"},{v: new Date(2011, 6, 19, 14, 11, 34)},{v: 53},{v: 27},{v: "e8fe3a06-b202-11e0-92dd-495a2db86d6d"},{v: 0.05},{v: true}]},
{c:[{v: "mydomain.com"},{v: "1650"},{v: "034534580"},{v: new Date(2011, 6, 19, 14, 11, 34)},{v: 11},{v: 9},{v: "e8dfb9dc-b202-11e0-92dc-495a2db86d6d"},{v: 0.02},{v: true}]},
{c:[{v: "mydomain.com"},{v: "1650"},{v: "03453453600"},{v: new Date(2011, 6, 19, 14, 11, 11)},{v: 14},{v: 9},{v: "db7efd52-b202-11e0-92d6-495a2db86d6d"},{v: 0.02},{v: true}]},
{c:[{v: "mydomain.com"},{v: "1650"},{v: "0345345947"},{v: new Date(2011, 6, 19, 14, 9, 41)},{v: 42},{v: 21},{v: "a59314bc-b202-11e0-92c7-495a2db86d6d"},{v: 0.04},{v: true}]},
{c:[{v: "mydomain.com"},{v: "1653"},{v: "345345420"},{v: new Date(2011, 6, 19, 14, 9, 41)},{v: 28},{v: 0},{v: "a5a953f8-b202-11e0-92c8-495a2db86d6d"},{v: 0},{v: true}]},
{c:[{v: "mydomain.com"},{v: "1650"},{v: "353453120"},{v: new Date(2011, 6, 19, 14, 8, 52)},{v: 28},{v: 5},{v: "885515bc-b202-11e0-92bd-495a2db86d6d"},{v: 0.02},{v: true}]},
{c:[{v: "mydomain.com"},{v: "1653"},{v: "34534567"},{v: new Date(2011, 6, 19, 14, 8, 36)},{v: 10},{v: 3},{v: "7efc86d0-b202-11e0-92b8-495a2db86d6d"},{v: 0.02},{v: true}]},
{c:[{v: "mydomain.com"},{v: "1650"},{v: "34534584"},{v: new Date(2011, 6, 19, 14, 7, 43)},{v: 34},{v: 13},{v: "5f1cfb60-b202-11e0-92b2-495a2db86d6d"},{v: 0.02},{v: true}]},
{c:[{v: "mydomain.com"},{v: "1653"},{v: "34534534561"},{v: new Date(2011, 6, 19, 14, 6, 52)},{v: 52},{v: 0},{v: "411b3faa-b202-11e0-92ab-495a2db86d6d"},{v: 0},{v: true}]}]}
我只有儘可能 var o = JObject.Parse(results); var records = o.SelectToken("rows").Select(s => s).ToList();
理想情況下,我想拉的記錄回一類如
public class CallDetailRecord
{
public String Name { get; set; }
public String CallerIdNumber { get; set; }
public String DestinationNumber { get; set; }
public DateTime CallStart { get; set; }
public int Duration { get; set; }
public String Uuid { get; set; }
public Decimal CallBillTotal { get; set; }
public bool Recorded { get; set; }
}
非常感謝任何幫助。
我今天發現了數據使用[谷歌的數據可視化API]生產(http://code.google.com/apis/chart/interactive/docs/reference.html) 使許多更有突然感覺到。 – Mechamonkey