I have serialized the Body class in Kinect v2 by converting it into List and saved the data in a text file. But when I deserialize it back to the List object, I am not able to do it. It says"Unable to find a constructor to use for type Microsoft.Kinect.Body. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute". I am using the following code.
List<Body> newbodies = new List<Body>();
newbodies = JsonSerialization.ReadFromJsonFile<List<Body>> ("skeletonData.txt");
public static T ReadFromJsonFile<T>(string filePath) where T : new()
{
TextReader reader = null;
try
{
reader = new StreamReader(filePath);
var fileContents = reader.ReadToEnd();
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(fileContents);
}
finally
{
if (reader != null)
reader.Close();
}
}