gpt4 book ai didi

jquery - Json 解析错误 : JSON. 解析:字符串文字中的控制字符错误

转载 作者:行者123 更新时间:2023-12-01 06:12:08 27 4
gpt4 key购买 nike

我已经使用移动 jquery 为移动网站创建了 Web 服务,它将返回 json 字符串。当我开始使用 jQuery.parseJSON 方法解析这个 json 时,有时它工作正常,但在某些情况下,它会给出如下错误: JSON.parse: bad control character in string literal

我已经在 jsonlint.com 上验证了这个 json,并且它给出了有效的 json 消息。

Folwoing 是我的 json 字符串。

[{"ID":"468438","Text":"<a target='_blank' class='msg_links' href='http://bit.ly/jJa131' >http://bit.ly/jJa131</a> sdfdsfasd <br> <br> shankar (shankar) on Ogoing Small Business Social Network <br> <br> IT company ","CreatedText":"Jan 20 2012 6:01AM","UserID":"535","UserName":"shankar","FullName":"shankar","UpCategoryID":"8","UpCategoryName":"Deals","CategoryName":"Education & child care","IsRecommend":"False","RecommendUser":"","RecommendRating":"0","RecommendId":"0","LikedCount":"0","CommentsCount":"0","TotalRowCount":"1011","Attachment":"","RealFilename":"","Source":"","ImageURL":"http://ogoing.rigelnetworks.com/Images/Thumb/music_arts_icon_large_634666567215996287.jpg"},{"ID":"468437","Text":"<a target='_blank' class='msg_links' href='http://bit.ly/jJa131' >http://bit.ly/jJa131</a> asdfasdfasdfasdfasdf <br> shankar (shankar) on Ogoing Small Business Social Network <br> IT company ","CreatedText":"Jan 20 2012 5:35AM","UserID":"535","UserName":"shankar","FullName":"shankar","UpCategoryID":"8","UpCategoryName":"Deals","CategoryName":"Education & child care","IsRecommend":"False","RecommendUser":"","RecommendRating":"0","RecommendId":"0","LikedCount":"0","CommentsCount":"0","TotalRowCount":"1011","Attachment":"","RealFilename":"","Source":"","ImageURL":"http://ogoing.rigelnetworks.com/Images/Thumb/music_arts_icon_large_634666567215996287.jpg"},{"ID":"468434","Text":"asdfasdfasdf asdfasdfsadfasdfa ","CreatedText":"Jan 20 2012 4:55AM","UserID":"535","UserName":"shankar","FullName":"shankar","UpCategoryID":"8","UpCategoryName":"Deals","CategoryName":"Education & child care","IsRecommend":"False","RecommendUser":"","RecommendRating":"0","RecommendId":"0","LikedCount":"0","CommentsCount":"0","TotalRowCount":"1011","Attachment":"","RealFilename":"","Source":"","ImageURL":"http://ogoing.rigelnetworks.com/Images/Thumb/music_arts_icon_large_634666567215996287.jpg"},{"ID":"468433","Text":"asdfasdfasdf asdfasdf ","CreatedText":"Jan 20 2012 4:55AM","UserID":"535","UserName":"shankar","FullName":"shankar","UpCategoryID":"8","UpCategoryName":"Deals","CategoryName":"Education & child care","IsRecommend":"False","RecommendUser":"","RecommendRating":"0","RecommendId":"0","LikedCount":"0","CommentsCount":"0","TotalRowCount":"1011","Attachment":"","RealFilename":"","Source":"","ImageURL":"http://ogoing.rigelnetworks.com/Images/Thumb/music_arts_icon_large_634666567215996287.jpg"},{"ID":"468432","Text":"asdfasdfasdf ","CreatedText":"Jan 20 2012 4:54AM","UserID":"535","UserName":"shankar","FullName":"shankar","UpCategoryID":"8","UpCategoryName":"Deals","CategoryName":"Education & child care","IsRecommend":"False","RecommendUser":"","RecommendRating":"0","RecommendId":"0","LikedCount":"0","CommentsCount":"0","TotalRowCount":"1011","Attachment":"","RealFilename":"","Source":"","ImageURL":"http://ogoing.rigelnetworks.com/Images/Thumb/music_arts_icon_large_634666567215996287.jpg"},{"ID":"468012","Text":"Why this ? ","CreatedText":"Dec 20 2011 12:37AM","UserID":"537","UserName":"shankar","FullName":"shankar mahadevan","UpCategoryID":"1","UpCategoryName":"General","CategoryName":"Automotive","IsRecommend":"False","RecommendUser":"","RecommendRating":"0","RecommendId":"0","LikedCount":"1","CommentsCount":"0","TotalRowCount":"1011","Attachment":"","RealFilename":"","Source":"ogoing","ImageURL":"http://ogoing.rigelnetworks.com/Images/Thumb/img634661225851958174_org.png"},{"ID":"468011","Text":"Tixkhogclycyo ","CreatedText":"Dec 20 2011 12:37AM","UserID":"537","UserName":"shankar","FullName":"shankar mahadevan","UpCategoryID":"1","UpCategoryName":"General","CategoryName":"Automotive","IsRecommend":"False","RecommendUser":"","RecommendRating":"0","RecommendId":"0","LikedCount":"0","CommentsCount":"0","TotalRowCount":"1011","Attachment":"","RealFilename":"","Source":"ogoing","ImageURL":"http://ogoing.rigelnetworks.com/Images/Thumb/img634661225851958174_org.png"},{"ID":"468010","Text":"Zgkxxkxxhhl ","CreatedText":"Dec 20 2011 12:35AM","UserID":"537","UserName":"shankar","FullName":"shankar mahadevan","UpCategoryID":"1","UpCategoryName":"General","CategoryName":"Automotive","IsRecommend":"False","RecommendUser":"","RecommendRating":"0","RecommendId":"0","LikedCount":"0","CommentsCount":"0","TotalRowCount":"1011","Attachment":"","RealFilename":"","Source":"ogoing","ImageURL":"http://ogoing.rigelnetworks.com/Images/Thumb/img634661225851958174_org.png"},{"ID":"468009","Text":"Jfzkdlufil ","CreatedText":"Dec 20 2011 12:35AM","UserID":"537","UserName":"shankar","FullName":"shankar mahadevan","UpCategoryID":"1","UpCategoryName":"General","CategoryName":"Automotive","IsRecommend":"False","RecommendUser":"","RecommendRating":"0","RecommendId":"0","LikedCount":"0","CommentsCount":"0","TotalRowCount":"1011","Attachment":"","RealFilename":"","Source":"ogoing","ImageURL":"http://ogoing.rigelnetworks.com/Images/Thumb/img634661225851958174_org.png"},{"ID":"468007","Text":"hellooooooo ","CreatedText":"Dec 20 2011 12:21AM","UserID":"537","UserName":"shankar","FullName":"shankar mahadevan","UpCategoryID":"1","UpCategoryName":"General","CategoryName":"Automotive","IsRecommend":"False","RecommendUser":"","RecommendRating":"0","RecommendId":"0","LikedCount":"0","CommentsCount":"0","TotalRowCount":"1011","Attachment":"","RealFilename":"","Source":"ogoing","ImageURL":"http://ogoing.rigelnetworks.com/Images/Thumb/img634661225851958174_org.png"}]

请给我一个解决这个问题的方法。提前致谢。

最佳答案

您可以将 \n 替换为 \\n例如

yourJsonText = yourJsonText.Replace("\n","\\n");

但是如果你使用 asp.net ,最好通过

编码你的 json 字符串

yourJsonText = HttpUtility.JavaScriptStringEncode(yourJsonText)

关于jquery - Json 解析错误 : JSON. 解析:字符串文字中的控制字符错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9684925/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com