如何從這兩個相似的Json獲得模型結果: 我嘗試了各種方法,但仍然無法弄清楚。 在此先感謝...在Json解析中獲取模型
eg : result.ImagePath
1.
{"Success":"True"ImagePath":"D:\Wyo\PH\TS\Images\Preview\Admin\Toy\Soli.jpg"}
「2.
ContentResult類型爲JSON
Content="{"Success":"True"ImagePath":"D:\Wyo\PH\TS\Images\Preview\Admin\Toy\Soli.jpg"}"
Controller's sent data :
ContentResult result = Content("{\"Success\":\"" + vm.Success + "\"ImagePath\":\"" + vm.ImagePath + "\"}");
result.ContentType = "application/json"; //-- "application/json" //- "text/plain"
JsonResult jsResult = Json(result, JsonRequestBehavior.AllowGet);
return jsResult; //result
您的預期產出是多少?你想將你的JSON轉換爲類對象嗎? – Shyju 2014-08-29 14:20:21
只是想從這個響應中獲取ImagePath(json) – LastBye 2014-08-29 14:22:53
對於頻繁的json用戶來說,應該很容易,不要在這裏尋找綁定,ko或者這樣的事情,這兩個屬性都是簡單的字符串,它以json的形式傳遞。 – LastBye 2014-08-29 14:24:45