public string getAllAirports(string name) { var airports = _adminBLL.getAllAirports(name); var jsAirports = new List <jsAirport>(); foreach (Airport a in airports) { var anAirport = new jsAirport() { id = a.Id, name = a.Name }; jsAirports.Add(anAirport); } var jsonSerializer = new JavaScriptSerializer(); return(jsonSerializer.Serialize(jsAirports)); }