public static void WriteJson(Scheme scheme, string jsonPath) { Dictionary<string, object> dict = scheme.ToJsonObject(); string jsonStr = JsonConvert.SerializeObject(dict); Console.WriteLine("json path: {0}", jsonPath); using (StreamWriter w = new StreamWriter(jsonPath)) w.Write(jsonStr); }
private void Save_Click(object sender, RoutedEventArgs e) { var scheme = new Scheme { Rooms = editor.Rooms.ToArray(), Items = editor.Items.ToArray() }; var dialog = new SaveFileDialog { Filter = "Schemes|*.json||", AddExtension = true }; if (dialog.ShowDialog() == true) { Dictionary<string, object> dict = scheme.ToJsonObject(); string jsonStr = JsonConvert.SerializeObject(dict); File.WriteAllText(dialog.FileName, jsonStr); } }