public void Export(TextWriter writer) { new JsonSerializer { NullValueHandling = NullValueHandling.Include, DefaultValueHandling = DefaultValueHandling.Include, Formatting = Formatting.Indented }.Serialize(writer, new ExportRoot { Users = new List <ExportUser> (UserKeyStores.Select(userKeyStore => new ExportUser { UserKey = userKeyStore.User.Key, SyncedKeys = userKeyStore.SyncedKeys.ToArray(), FavoritesKeys = userKeyStore.FavoritesKeys.ToArray(), PlaylistsKeys = userKeyStore.PlaylistsKeys } )), Objects = ObjectStore.Export() }); writer.Flush(); }