public void Save(string name, LearningApi api) { var jsonApi = JsonConvert.SerializeObject(api, api.GetType(), getSettings()); using (FileStream fs = new FileStream($"{name}.json", FileMode.Create)) { using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8)) { sw.Write(jsonApi); } } }