public string[] getHistoricalData() // convert to json { string[] jsonArray; List <Historical> list; try { list = _stockScreenerService.GetHistoricalData(); jsonArray = new string[list.Count]; } catch (Exception ex) { if (ex is System.ArgumentNullException) { Console.WriteLine("Exception " + ex); } Console.WriteLine("Exception " + ex); return(null); } for (int i = 0; i < list.Count; i++) { jsonArray[i] = JsonSerializer.Serialize(list[i]); } return(jsonArray); }