2015-02-05 58 views
1

我想從一個Web方法函數返回的字符串值,目前其返回JSON數組值:如何將JSON數組轉換爲字符串..?

{"statusCode":200,"result":{"totalCount":1,"resultCount":1,"items":[{"Category":"Content Types","Database":"master","DisplayName":"New Home","HasChildren":false,"Icon":"/temp/IconCache/Network/16x16/home.png","ID":"{7FA85E0C-5E09-4B8E-9F1C-B362D562FADD}","Language":"en","LongID":"/{11111111-1111-1111-1111-111111111111}/{0DE95AE4-41AB-4D01-9EB0-67441B7C2450}/{8418FEEC-DC96-42C5-AC38-AD3942497A18}/{7FA85E0C-5E09-4B8E-9F1C-B362D562FADD}","MediaUrl":"/~/icon/Network/48x48/home.png.aspx","Name":"New Home","Path":"/sitecore/content/Content Types/New Home","Template":"User Defined/test /Content Types/Home","TemplateId":"{8112E624-DAD0-429C-A185-BE4A82A2D648}","TemplateName":"Home","Url":"~/link.aspx?_id=7FA85E0C5E094B8E9F1CB362D562FADD\u0026amp;_z=z","Version":1,"Fields":{}}]}} 

我試圖像這樣的東西將其轉換爲字符串:

System.Web.Script.Serialization.JavaScriptSerializer js = new  System.Web.Script.Serialization.JavaScriptSerializer(); 
     var table = js.DeserializeObject<string>(jsonArray); 

能有人幫助我如何做到這一點。

+0

迭代,並在新的字符串concate值。 tempVar + = value; – 2015-02-05 14:25:31

回答

2

你可以嘗試這樣的:通過他們

 var strOuptut = readStream.ReadToEnd(); 
     Newtonsoft.Json.Linq.JObject obj = Newtonsoft.Json.Linq.JObject.Parse(strOuptut); 
     StringBuilder html = new StringBuilder(); 
相關問題