改为System.Text.Json:

This commit is contained in:
Slnanx 2024-11-17 15:24:57 +08:00
parent 75a4151a5d
commit ca3082226e
3 changed files with 8 additions and 16 deletions

View file

@ -7,7 +7,7 @@
* - System.Collections.Generic * - System.Collections.Generic
* - System.Globalization * - System.Globalization
* - System.IO * - System.IO
* - Newtonsoft.Json * - System.Text.Json
* *
* : * :
* - JSON文件en.jsonzh.json * - JSON文件en.jsonzh.json
@ -25,16 +25,13 @@
* "Restart_v2rayN": "正在重启,请等待...", * "Restart_v2rayN": "正在重启,请等待...",
* "Guidelines": "请从主应用运行!" * "Guidelines": "请从主应用运行!"
* } * }
*
* :
* - NuGet安装了Newtonsoft.Json库
*/ */
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Text.Json;
public class Localization public class Localization
{ {
@ -68,7 +65,7 @@ public class Localization
// 读取JSON文件内容 // 读取JSON文件内容
var json = File.ReadAllText(jsonFilePath); var json = File.ReadAllText(jsonFilePath);
// 解析JSON内容 // 解析JSON内容
translations = JsonConvert.DeserializeObject<Dictionary<string, string>>(json); translations = JsonSerializer.Deserialize<Dictionary<string, string>>(json);
return true; // 成功读取和解析JSON文件 return true; // 成功读取和解析JSON文件
} }
catch (Exception ex) catch (Exception ex)

View file

@ -4,8 +4,10 @@
* 使 * 使
* *
* : * :
* - System * - System.Collections.Generic
* - System.Threading * - System.Globalization
* - System.IO
* - System.Text.Json
* *
* : * :
* - JSON文件en.jsonzh.json * - JSON文件en.jsonzh.json
@ -23,9 +25,6 @@
* "Restart_v2rayN": "正在重启,请等待...", * "Restart_v2rayN": "正在重启,请等待...",
* "Guidelines": "请从主应用运行!" * "Guidelines": "请从主应用运行!"
* } * }
*
* :
* - NuGet安装了Newtonsoft.Json库
*/ */
using System; using System;

View file

@ -4,11 +4,10 @@
* 使 * 使
* *
* : * :
* - System
* - System.Collections.Generic * - System.Collections.Generic
* - System.Globalization * - System.Globalization
* - System.IO * - System.IO
* - Newtonsoft.Json * - System.Text.Json
* *
* : * :
* - JSON文件en.jsonzh.json * - JSON文件en.jsonzh.json
@ -26,9 +25,6 @@
* "Restart_v2rayN": "正在重启,请等待...", * "Restart_v2rayN": "正在重启,请等待...",
* "Guidelines": "请从主应用运行!" * "Guidelines": "请从主应用运行!"
* } * }
*
* :
* - NuGet安装了Newtonsoft.Json库
*/ */
using System; using System;