using System.Collections.Generic; // 根据 JSON 文件 生成对应的 C# 对象;网址:https://json2csharp.com/ // 1. 将 config.json 文件复制到网址中 // 2. 将得到的内容复制到 namespace HH.WCS.Mobox3.{项目代号}.AppStart { } 大括号内部(C# 10 才支持 文件范围内的命名空间) // 3. 将 Root 更名为 Config // 补充:这种方式没法保留注释,需要熟悉 Config 文件的字段含义(暂不考虑代码生成 Json 文件) namespace HH.WCS.Mobox3.DSZSH.AppStart { // Root myDeserializedClass = JsonConvert.DeserializeObject(myJsonResponse); public class Area { public string Name { get; set; } public List Codes { get; set; } } public class ProductionLine { public string Id { get; set; } public string Name { get; set; } public string PlcIp { get; set; } public int PlcPort { get; set; } public int SlaveId { get; set; } public List OnLoc { get; set; } public List OffLoc { get; set; } } public class Config { public string WebApiUrl { get; set; } public string NdcApiUrl { get; set; } public string SqlServer { get; set; } public string TcpServerIp { get; set; } public int TcpServerPort { get; set; } public List Areas { get; set; } public List Tasks { get; set; } public List ProductionLines { get; set; } } public class Task { public string Name { get; set; } public List StartAreas { get; set; } public List EndAreas { get; set; } } }