我有一个 VB.Net 的Web服务,它返回的数据是一个JSON字符串。返回的某些数据中可能包含 EMOJI。当我返回没有EMOJI的数据时,数据返回正常。
喜欢这个-
[
{
"ImgID": "150",
"ImgDesc": "Added to your portfolio",
"PublicID": "c0lbquvzitd3igohfh7x",
"ImgURL": "test.com",
"LikeCount": "0",
"CommentCnt": "2",
"PickCount": "",
"ServerUpdateDate": "1/17/2016 3:13:21 PM",
"UserName": "Deathstarspa",
"ProfileImgID": "hqhoiohfckzldgpdem6k",
"Location": "Chester County, PA, USA",
"dltflg": "False",
"PortName": "2 0 1 6 | M E N S",
"Categories": "Blowouts"
},
{
"ImgID": "151",
"ImgDesc": "Stone cold",
"PublicID": "udecff1bi0ymhewp1qlv",
"ImgURL": "Test.com",
"LikeCount": "0",
"CommentCnt": "0",
"PickCount": "",
"ServerUpdateDate": "1/17/2016 3:17:26 PM",
"UserName": "Deathstarspa",
"ProfileImgID": "hqhoiohfckzldgpdem6k",
"Location": "Chester County, PA, USA",
"dltflg": "False",
"PortName": "2 0 1 6 | M E N S",
"Categories": "Test"
}
]
如果数据在刺痛的任何地方都有表情符号,则字符串将在最后被切断。
表情符号在数据中的位置并不重要。
喜欢-
[
{
"ImgID": "161",
"ImgDesc": "Bed ?????",
"PublicID": "gnw6ooo04ls21kqq8doo",
"ImgURL": "test.com",
"LikeCount": "0",
"CommentCnt": "0",
"PickCount": "",
"ServerUpdateDate": "2/11/2016 8:18:03 PM",
"UserName": "Deathstarspa",
"ProfileImgID": "hqhoiohfckzldgpdem6k",
"Location": "Chester County, PA, USA",
"dltflg": "False",
"PortName": "Bed Pics",
"Categories": "Blowouts,Treatments"
},
{
"ImgID": "162",
"ImgDesc": "Bed ?????",
"PublicID": "lrdxpvwxoq5zxpkagamo",
"ImgURL": "test.com",
"LikeCount": "0",
"CommentCnt": "0",
"PickCount": "",
"ServerUpdateDate": "2/11/2016 8:18:05 PM",
"UserName": "Deathstarspa",
"ProfileImgID": "hqhoiohfckzldgpdem6k",
"Location": "Chester County, PA, USA",
"dltflg": "False",
"PortName": "Test Pics"
虽然你在ImgDesc作品中看不到表情符号,但?????
代表表情符号。因此,带有ImgID 161
的记录是完整的,但具有ImgID
的记录162
在"Test Pics,"
处被截断。如果我从ImgDesc中删除表情符号,那么数据就会恢复正常。
我正在与VB.NET
合作,并参考了Newtonsoft.Json dll
。
我需要做些什么来使表情符号不会引起问题吗?
您需要根据 JSON 标准正确编码表情符号。请参阅下面的相关答案:
如何在 C# 中反序列化 json 中的表情符号