格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数时出错

时间:2011-06-23 17:29:57

标签: json deserialization

我在我的jquery代码中创建一个数组然后调用stringify使其成为json数据然后调用一个接收对象的服务,但不幸的是我收到了这个错误,这个错误是由于我的对象由数组属性组成,我有相同的代码,当我的对象只是字符串和数字时,它都正常工作....这是我的对象的一部分

[Serializable]
[DataContract]
public class ImagesEditInfo
{

    [DataMember(IsRequired=true)]
    public int[] ImageIds
    {
        get;
        set;
    }

}

任何人都可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

您的服务是什么样的,您能提供一些样品申请吗?

我大约将此用于服务电话

    $.ajax({
        type: 'POST',
        url: serviceURL,
        contentType: 'application/json',
        data: JSON.stringify({ serviceParameterName: javascriptObject }),
        success: successFunction,
        dataType: 'json'
    });

在您的情况下,您的服务方法必须是这样的:

    [OperationContract]
    [WebInvoke(ResponseFormat = WebMessageFormat.Json, UriTemplate = serviceURL, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
    public string methodName(ImagesEditInfo serviceParameterName) { }
相关问题