当表情符号在数据中时,JSON字符串被截止

时间:2016-05-27 12:25:11

标签: json vb.net json.net emoji

我有一个返回数据的VB.Net Webservice是一个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"
  }
]

如果数据在sting中的任何地方都有一个表情符号,那么字符串会在最后被截断。

表情符号在数据中的位置无关紧要。

喜欢 -

[
  {
    "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片段中看不到Emojis,?????代表表情符号。因此,ImgID 161的记录已完成,但ImgID 162的记录在"Test Pics,"处被截止。如果我从ImgDesc中删除表情符号,那么数据会恢复正常。

我正在使用VB.NET,我引用了Newtonsoft.Json dll

我需要做些什么吗表情符号不会导致问题吗?

1 个答案:

答案 0 :(得分:3)

根据JSON标准,您需要对表情符号进行正确编码。请参阅以下相关答案:

how can I Deserialize emoji in json in C#