I was using the following to convert my properties to JSON in windows and it is working very well but now I am trying to do the same in Xamarin on my Mac but it is unable to recognize DataContractJsonSerializer. Below is the code i was using on windows:
public static string JsonSerializer(T t)
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));
MemoryStream ms = new MemoryStream();
ser.WriteObject(ms, t);
string jsonString = Encoding.UTF8.GetString(ms.ToArray());
ms.Close();
//Replace Json Date String
string p = @"\\/Date\((\d+)\+\d+\)\\/";
MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString);
Regex reg = new Regex(p);
jsonString = reg.Replace(jsonString, matchEvaluator);
return jsonString;
}
Can anyone in finding a workaround so that i can use this in my Xamarin.Mac project.