Javascript json错误无效的JSON原语:strJson(Javascript json error Invalid JSON primitive: strJson)

编程入门 行业动态 更新时间:2024-10-28 16:20:12
Javascript json错误无效的JSON原语:strJson(Javascript json error Invalid JSON primitive: strJson)

我写了一个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#func是

[WebMethod] public static int Vonvert(string strJson) { //DataSet dt1 = JsonConvert.DeserializeObject<DataSet>(strJsonssss); return 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...

最满意答案

你错过了收盘报价:

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

You are missing a closing quote:

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

更多推荐

本文发布于:2023-07-22 02:16:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1216035.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   JSON   Javascript   json   Invalid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!