public static string ToJson(ConfigureFile configurefile) { List <ConfigureFile> listconfigurefile = new List <ConfigureFile>(); listconfigurefile.Add(configurefile); StringBuilder strjson = new StringBuilder(JsonMapper.ToJson(listconfigurefile)); strjson = strjson.Replace("[", ""); strjson = strjson.Replace("]", ""); return(ConvertJsonString(strjson.ToString())); }
/// <summary> /// 初始化创建josn字符串 /// </summary> /// <returns>返回josn字符串</returns> public static string ToJson() { ConfigureFile configurefile = new ConfigureFile(); List <ConfigureFile> listconfigurefile = new List <ConfigureFile>(); listconfigurefile.Add(configurefile); StringBuilder strjson = new StringBuilder(JsonMapper.ToJson(listconfigurefile)); strjson = strjson.Replace("[", ""); strjson = strjson.Replace("]", ""); //strjson = strjson.Replace("{", "{\n\t"); //strjson = strjson.Replace(",", ",\n\t"); //strjson = strjson.Insert(strjson.ToString().LastIndexOf("}"), "}\n"); MessageBox.Show(ConvertJsonString(strjson.ToString())); return(ConvertJsonString(strjson.ToString())); }
/// <summary> /// litjosn解析字符串对应类 /// </summary> /// <returns>返回ConfigureFile对象</returns> public static ConfigureFile ReadJosn() { ConfigureFile configurefile = JsonMapper.ToObject <ConfigureFile>(ReadFile()); return(configurefile); }