0
我在我的jQuery代碼中創建一個數組,然後調用stringify使其成爲json數據,然後調用一個服務接收一個對象,但不幸的是我得到這個錯誤,並且這個錯誤是由於我的對象由數組屬性組成,我有相同的代碼,並且當我的對象只有字符串和數字時它們都工作正常。這是我的對象格式化程序在嘗試反序列化消息時拋出一個異常:嘗試反序列化參數時發生錯誤
[Serializable]
[DataContract]
public class ImagesEditInfo
{
[DataMember(IsRequired=true)]
public int[] ImageIds
{
get;
set;
}
}
誰能幫助請的一部分嗎?
當然,是這樣的。 – user510336
[OperationContract的] [WebInvoke(ResponseFormat = WebMessageFormat.Json,方法= 「POST」,BodyStyle = WebMessageBodyStyle.Wrapped,UriTemplate = 「ImagesEdit」)] 公共字符串UpdateImages(ImagesEditInfo ImagesInfo) { } $就({ 網址: 「服務URL」, 數據類型: 'JSON' 類型: '後', 過程數據:假的, 的contentType: '應用/ JSON', 數據: '數據後', - 這是字符串化對象 成功:function(){ //成功執行任何操作 return; }, – user510336
這是我如何創建對象 var serviceData = {ImageIds:imageids,ImageNames:imagenames,ImageDescriptions:imagedescriptions,imagetags:ImageTags,IsDownloadable:isdownloadables,IsCommentable:iscommentables}; serviceData = {ImagesInfo:serviceData}; – user510336