亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 ConfuserEx 時 Newtonsoft JSON 反序列化不起作用

使用 ConfuserEx 時 Newtonsoft JSON 反序列化不起作用

C#
收到一只叮咚 2022-01-15 19:31:22
我有一個這樣的 JSON 類:public class UpdateCheck{    public bool UpdatesAvailable { get; set; }    public string LinkOfNewVersion { get; set; }}但是當我使用 ConfuserEx 混淆我的程序集時, UpdatesAvailableand的值是空的:/LinkOfNewVersion我已經嘗試了以下所有方法:在我的 JSON 類上方添加[Obfuscation(Exclude = false, Feature = "-rename")]屬性:[Obfuscation(Exclude = false, Feature = "-rename")]public class UpdateCheck{    public bool UpdatesAvailable { get; set; }    public string LinkOfNewVersion { get; set; }}在我的 JSON 類上方添加[Serializable]屬性:[Serializable]public class UpdateCheck{    public bool UpdatesAvailable { get; set; }    public string LinkOfNewVersion { get; set; }}在我的 JSON 類上方添加兩個屬性:[Serializable][Obfuscation(Exclude = false, Feature = "-rename")]public class UpdateCheck{    public bool UpdatesAvailable { get; set; }    public string LinkOfNewVersion { get; set; }}但是我嘗試過的所有方法都失敗了:/我的混淆屬性:  <rule pattern="true" preset="maximum" inherit="false">    <protection id="anti ildasm" />    <protection id="anti tamper" />    <protection id="constants" />    <protection id="ctrl flow" />    <protection id="anti dump" />    <protection id="anti debug" />    <protection id="invalid metadata" />    <protection id="ref proxy" />    <protection id="resources" />    <protection id="typescramble" />    <protection id="rename" />  </rule>當我從 ConfuserEx 配置文件中刪除“重命名”保護時,我的程序集會像這樣崩潰:
查看完整描述

2 回答

?
慕尼黑8549860

TA貢獻1818條經驗 獲得超11個贊

嘗試使用JsonProperty屬性將字段名稱設置為其固定值:


public class UpdateCheck

{

    [JsonProperty("UpdatesAvailable")]

    public bool UpdatesAvailable { get; set; }


    [JsonProperty("LinkOfNewVersion")]

    public string LinkOfNewVersion { get; set; }

}


查看完整回答
反對 回復 2022-01-15
?
楊__羊羊

TA貢獻1943條經驗 獲得超7個贊

您必須專門刪除“名稱”和“類型爭奪”選項。使用“無”以上的任何預設都包括“名稱”,這是主要問題。我在沒有這兩個的情況下使用最大預設,沒有關于 Json 的問題。


查看完整回答
反對 回復 2022-01-15
  • 2 回答
  • 0 關注
  • 705 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號