I tried many different codes to deserialize the objects from a Json_List but every time the list, in which my objects should be saved gets the null value even after the deserialization. BTW I am using the Newtonsoft.Json Namespace. It worked just fine when I serialized the objects but its a total fail when deserializing.
public void Load(string fileName)
{
//I found a way that works but its trivial and I think it can be done with a better code without using
// an array and a loop
Curve[] arrCurves = new Curve[1024];
JsonSerializer ser = new JsonSerializer { TypeNameHandling = TypeNameHandling.Auto };
using (TextReader reader = File.OpenText(fileName))
{
_curves.Clear();
//_curves.Add(ser.Deserialize(reader, typeof(Curve)) as Curve);
//_curves.Add(ser.Deserialize(reader, typeof(List<Curve>)) as Curve);
arrCurves = ser.Deserialize(reader, typeof(Curve[])) as Curve[];
for (int i = 0; i < arrCurves.Length; i++)
{
_curves.Add(arrCurves[i]);
}
}
}
The code works btw but I want to know if i can do it without the loop and also the "_curves" List is a readonly List