柚子快報激活碼778899分享:C# 讀取JSON文件
柚子快報激活碼778899分享:C# 讀取JSON文件
命名空間:
using System.Text.Json.Nodes;
讀取JSON:
// 讀取設(shè)置文件參數(shù)
JsonNode json = JsonNode.Parse(File.ReadAllText(Environment.CurrentDirectory.Replace("\\bin\\Debug", "") + "\\settings.json"))["appSettings"];
// 畫布參數(shù)設(shè)置
JsonNode canvas = json["canvas"];
this.qrWidth.Text = canvas["width"].GetValue
this.qrHeight.Text = canvas["height"].GetValue
settings.json 文件內(nèi)容:
{
"appSettings": {
"authorizationCode": {
"server": "",
"code": "13014596002",
"msgTitle": "請先授權(quán)",
"msgContent": "請先輸入授權(quán)碼,點擊驗證按鈕!",
"failureTitle": "授權(quán)失敗",
"failureContent": "授權(quán)失敗,校驗未通過,請重驗證!",
"success": "校驗成功"
},
"canvas": {
"width": 300,
"height": 244
}
}
}
柚子快報激活碼778899分享:C# 讀取JSON文件
推薦閱讀
本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點和立場。
轉(zhuǎn)載請注明,如有侵權(quán),聯(lián)系刪除。