2016-03-30 25 views
-4
{ 
    "response_code": "AVAILABLE", 
    "remittance": { 
     "transaction_id": "c2e7de4a-7646-4ff4-986c-e5a0c87c48d8", 
     "status": "NEW", 
     "source_reference_number": "RN-0006", 
     "remitter": { 
      "name": "Juan Dela Cruz", 
      "first_name": null, 
      "middle_name": null, 
      "last_name": null, 
      "contact_number": null, 
      "account_number": null, 
      "address": { 
       "address_1": "Manila", 
       "country": "PH" 
      }, 
      "identification": { 
       "name": "SSS", 
       "number": "2313", 
       "type": "SSS_ID", 
       "expiry_date": "2018-01-01", 
       "place_of_issue": "Manila" 
      } 
     }, 
     "beneficiary": { 
      "name": "Jane Dela Cruz", 
      "first_name": null, 
      "middle_name": null, 
      "last_name": null, 
      "contact_number": null, 
      "account_number": null, 
      "address": { 
       "address_1": "Manila", 
       "country": "PH" 
      }, 
      "identification": { 
       "name": "", 
       "number": "", 
       "type": "", 
       "expiry_date": null, 
       "place_of_issue": "" 
      } 
     }, 
     "payout_amount": { 
      "currency": "PHP", 
      "amount": "5000.00" 
     }, 
     "remarks": null, 
     "value_date": "2016-03-21", 
     "date_created": "2016-03-21 07:24:44 UTC" 
    }, 
    "response_message": "Transaction Available For Payout." 
} 

winformを使用してjsonでこの応答を得ました。これを配列として変換します。Json配列の文字列に変換

+0

あなたを停止していますか? – Guy

+0

Jsonについてはかなりの質問があります。あなたが助けてくれた人がいるかどうかを見ましたか? – crashmstr

+0

なぜこれを配列として保存したいですか?確かにそれは地図として表現する必要があります... –

答えて

0

オンサイトjson2csharp.com JSONのgenereteクラス。 JSONを生成されたクラスにデシリアライズします。ツールは理想的なクラスではないので、注意してください。

public class Address 
{ 
    public string address_1 { get; set; } 
    public string country { get; set; } 
} 

public class Identification 
{ 
    public string name { get; set; } 
    public string number { get; set; } 
    public string type { get; set; } 
    public string expiry_date { get; set; } 
    public string place_of_issue { get; set; } 
} 

public class Remitter 
{ 
    public string name { get; set; } 
    public object first_name { get; set; } 
    public object middle_name { get; set; } 
    public object last_name { get; set; } 
    public object contact_number { get; set; } 
    public object account_number { get; set; } 
    public Address address { get; set; } 
    public Identification identification { get; set; } 
} 

public class Beneficiary 
{ 
    public string name { get; set; } 
    public object first_name { get; set; } 
    public object middle_name { get; set; } 
    public object last_name { get; set; } 
    public object contact_number { get; set; } 
    public object account_number { get; set; } 
    public Address address { get; set; } 
    public Identification identification { get; set; } 
} 

public class PayoutAmount 
{ 
    public string currency { get; set; } 
    public string amount { get; set; } 
} 

public class Remittance 
{ 
    public string transaction_id { get; set; } 
    public string status { get; set; } 
    public string source_reference_number { get; set; } 
    public Remitter remitter { get; set; } 
    public Beneficiary beneficiary { get; set; } 
    public PayoutAmount payout_amount { get; set; } 
    public object remarks { get; set; } 
    public string value_date { get; set; } 
    public string date_created { get; set; } 
} 

public class RootObject 
{ 
    public string response_code { get; set; } 
    public Remittance remittance { get; set; } 
    public string response_message { get; set; } 
} 

そしてクラスにJSON.NETデシリアライズオブジェクトを使用して:

string json = "...Your json..." 
RootObject ro = JsonConvert.DeserializeObject<RootObject>(json); 
関連する問題