2012-12-03 56 views

回答

3

類通過複製整個JSON數據串生成類 使用http://json2csharp.net

然後

public async Task<string>getData() 
     { 
      HttpClient client=new HttpClient(); 
    String URL="your string";//url for the JSON response 
    HttpResponseMessage response=await client.GetAsync(URL); 
    Return await response.Content.ReadAsStringAsync(); 
    } 

    private void async Button1_click() 
    { 
     string responseText= await getData(); 
DataContractJsonSerializer= new DataContractJsonSerializer(typeOf(RootObject));//DataContractJsonSerializer is the class object that u will generate 
RootObject root; 
Using(MemoryStream stream=new MemoryStream(Encoding.Unicode.GetBytes(responseText))) 
{ 
    //access properties here 
} 
} 
+0

感謝網址和使用JSON對象的代碼 – Harshit

+0

快樂希望我幫助 – Apoorv

相關問題