using Newtonsoft.Json.Linq; using Newtonsoft.Json; using NLog.Fluent; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HH.WCS.HGXCL.util { public class JsonHelper { public static string GetValue(string name) { try { var jsonFile = System.AppDomain.CurrentDomain.BaseDirectory+ "json\\Config.json"; using (System.IO.StreamReader file = System.IO.File.OpenText(jsonFile)) { using (JsonTextReader reader = new JsonTextReader(file)) { JObject o = (JObject)JToken.ReadFrom(reader); var value = o[name].ToString(); return value.Replace("\r\n", ""); } } } catch (Exception ex) { return "-1"; } } } }