2017-08-15 88 views
0

我在數據庫中的某些文本中的數據中有隱形\ u200c字符,當我在ASP.net API中返回XML格式的結果時,結果顯示正確,但是在與Newtonsoft.Json序列化時「\ u200c」字符串出現在結果中。有沒有牛頓軟件的任何設置來解決它?防止在NewtonSoft Json結果中的decode u200c字符

JSON:

{ 
      "rowClass": "someData", 
      "fieldName": "someData", 
      "description": "xxxx \u200cxxxxx", 

    } 

類:

public class Dto 
{ 
    public string RowClass { get; set; } 
    public string FieldName { get; set; } 
    public string Description { get; set; } 

} 
+0

請閱讀[問]並提供[mcve]。 [此示例](https://dotnetfiddle.net/CDvkMz)不會重現此問題。 – CodeCaster

回答

1

你們看到的是預期的行爲。在JSON中,字符串中的不可打印字符編碼爲\u +四個十六進制數字,其中的數字是字符的Unicode(UTF-16)表示。當您反序列化JSON時,編碼的十六進制數字將被轉換回原始字符。所以,不,沒有辦法「修復」這個,因爲串行器工作正常。