/// <summary> /// Gets JSON for object and displays it in the panel /// </summary> /// <typeparam name="T">The Type of object used for JSON Serializing</typeparam> /// <param name="Obj">The Object</param> public void Export <T>(T Obj) { Data_JSON.SelectAll(); Data_JSON.Selection.Text = Newtonsoft.Json.JsonConvert.SerializeObject(Obj, new Newtonsoft.Json.JsonSerializerSettings() { Formatting = Newtonsoft.Json.Formatting.Indented, NullValueHandling = Newtonsoft.Json.NullValueHandling.Include }); }
public T Import <T>() { Data_JSON.SelectAll(); try { return(Newtonsoft.Json.JsonConvert.DeserializeObject <T>(Data_JSON.Selection.Text)); } catch { MessageBox.Show("Invalid JSON!"); return((T)Activator.CreateInstance(typeof(T), new object[] { })); } }