I have been searching for a simple way to convert a dataset from a PostgreSQL database to JSON for use in a project that I am building.
This is my first time using J
public static T WriteJson(this System.Data.DataSet dataSet) { try { XmlDocument doc = new XmlDocument(); doc.LoadXml(dataSet.GetXml()); return (T)Convert.ChangeType(JsonConvert.SerializeXmlNode(doc).Replace("null", "\"\"").Replace("'", "\'"), typeof(T)); } catch (Exception ex) { throw ex; } }