1

I've written a jQuery demo to post JSON:

$.ajax({
    url: "RoleFunc.aspx/Vonvert",
    type: "POST",
    contentType: "application/json; charset=utf-8",
    dataType: 'json',
    data: { "strJson": json },                   

    success: function(result) {
        alert(result);    
    },
    error: function() {
        alert("error");
    }
});

and when I use the function, Firebug view shows as an error message like Invalid JSON primitive: strJson.

I've tested the JSON and the result is

{ "strJsonssss":[{"Role_ID":"2","Customer_ID":"155","Brands":"Chloe;","Country_ID":"96;"}]}

and my C# func is

[WebMethod]
public static int Vonvert(string strJson)
{
    //DataSet dt1 = JsonConvert.DeserializeObject<DataSet>(strJsonssss);   

    return 1;
}

I debug it, and it never in to the function so... any body help me...

4

2 回答 2

4

您缺少结束语:

{ "strJsonssss":[{"Role_ID":"2","Customer_ID":"155","Brands":"Chloe;","Country_ID":"96;"}]}
--------------^
于 2013-11-05T09:36:30.780 回答
0

此外,您可以使用此在线工具验证和验证您的 json 对象。http://jsonformatter.curiousconcept.com/#jsonformatter

于 2013-11-05T09:43:22.837 回答