private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { string imgJson1 = JsonConvert.SerializeObject(img1); System.IO.File.AppendAllText($"{DateTime.Now.ToString("yyyyMMddHHmmssffff")}_img.json", imgJson1); //string imgJson1 = JsonConvert.SerializeObject(img1); }
Updated
private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var settings = new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }; string imgJson1 = JsonConvert.SerializeObject(img1, Formatting.Indented, settings); System.IO.File.AppendAllText($"{DateTime.Now.ToString("yyyyMMddHHmmssffff")}_img.json", imgJson1); //string imgJson1 = JsonConvert.SerializeObject(img1); }
var settings = new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
};
string imgJson1 = JsonConvert.SerializeObject(img1, Formatting.Indented, settings);
标签:imgJson1,string,Parent,C#,Self,JsonConvert,SerializeObject,img1,ReferenceLoopHan From: https://www.cnblogs.com/Fred1987/p/18235755