public static string SAVE_TO_JSON(TargetManagerDataModel targets, ToolsNavigationDataModel <LayoutDocument> navigation, ToolLayout dockingLayout, IReadOnlyList <LayoutDocument> floatingLayout, string file) { using var ms = new MemoryStream(); using var writer = new Utf8JsonWriter(ms, new JsonWriterOptions() { Indented = true }); writer.WriteStartObject(); writer.WritePropertyName("Targets"); TargetManagerDataModel.SAVE_TO_JSON(writer, targets); writer.WritePropertyName("Docking"); navigation.ExportDockingToolboxToJSON(writer, dockingLayout); writer.WritePropertyName("Floating"); navigation.ExportFloatingToolboxToJSON(writer, floatingLayout); writer.WriteEndObject(); writer.Flush(); using var fs = new FileStream(file, FileMode.Create, FileAccess.Write); ms.Seek(0, SeekOrigin.Begin); ms.CopyTo(fs); fs.Flush(); return(Encoding.UTF8.GetString(ms.ToArray())); }