【问题标题】:Javascript json error Invalid JSON primitive: strJsonJavascript json错误无效的JSON原语:strJson
【发布时间】:2013-11-05 09:35:29
【问题描述】:

我写了一个 jQuery 演示来发布 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");
    }
});

当我使用该功能时,Firebug 视图显示为错误消息,如 Invalid JSON primitive: strJson.

我已经测试了 JSON,结果是

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

而我的 C# 函数是

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

    return 1;
}

我调试它,它从来没有进入函数所以...任何机构帮助我...

【问题讨论】:

    标签: c# javascript jquery json


    【解决方案1】:

    您缺少结束语:

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

    【讨论】:

    • 对不起..我问的时候错过了结束语...~~它已经有了
    • 我不明白你的意思,但如果你的问题解决了,那我很高兴:)
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-31
      • 2015-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-24
      • 2014-08-18
      • 2020-12-29
      相关资源
      最近更新 更多