0

Json.Netライブラリを使用しています。そして、JSONオブジェクトをc#オブジェクトに戻すのに問題があります。

私は現在持っています:JSON

[{"Datum":"31-05-2012","Naam":"KN: xxxx","Prijs":"37","Id":31123,"status":"found","foundPrice":"37.50","betaald":"2012-06-01","ingepakt":"2012-06-03","geanuleerd":"nee","verstuurd":"nee","achternaam":"xxxx","straat":"xxxx 98","postcode":"4422xx","plaats":"xxxxx","land":"Nederland","gewicht":"0.600"},{"Datum":"31-05-2012","Naam":"xxxxT","Prijs":"23","Id":31341,"status":"found","foundPrice":"23.00","betaald":"2012-06-01","ingepakt":"2012-06-03","geanuleerd":"nee","verstuurd":"nee","achternaam":"xxxx","straat":"de xxxxx 2","postcode":"4444xx","plaats":"xxxx","land":"Nederland","gewicht":"0.300"}]

およびオブジェクト:

public class OrderObject
{
    public string Datum, Naam, Prijs;
    public int Id;
    public string status;
    public string foundPrice;
    public string betaald;
    public string ingepakt;
    public string geanuleerd;
    public string verstuurd;
    public string achternaam;
    public string straat;
    public string postcode;
    public string plaats;
    public string land;
    public string gewicht;
}

これらのオブジェクトのリストをJSONに作成するには、次のものだけが必要です。

private void sentToServer(List<OrderObject> input )
        {
            var inputJson = JsonConvert.SerializeObject(input); 
        }

しかし、逆のプロセスのために私は何をする必要がありますか?誰かが私を助けることができますか?

Thx Matthy

4

2 に答える 2

3
 var result = JsonConvert.DeserializeObject<List<OrderObject>>(inputJson);
于 2012-11-12T14:51:18.457 に答える
1

DeserializeObjectであるSerializeObjectへの相互メソッドを試してください。

List<OrderObject> list = JsonConvert.DeserializeObject<List<OrderObject>>(inputJson);
于 2012-11-12T14:57:29.593 に答える