Problem :
Currently I am facing some issues. I am trying to use C# with Json.NET. The problem is that I always get following error:
{"Unexpected character encountered while parsing value: e. Path '', line 0, position 0."}
So the way I amm using Json.NET is as below. I am having a Class which should be saved. The class looks like following:
public class mystats
{
public string mytime { get; set; }
public string myvalue { get; set; }
}
public class MyViewerStatsFormat
{
public List<stats> myviewerstats { get; set; }
public String myversion { get; set; }
public MyViewerStatsFormat(bool mychk)
{
this.myviewerstats = new List<stats>();
}
}
One of the object of this class will be filled and saved with following:
File.WriteAllText(tmpfile, JsonConvert.SerializeObject(current), Encoding.UTF8);
The saving part of the code works fine and the file exists and is filled. After that the file should be read back into the class with following code:
try
{
MyViewerStatsFormat mycurrent = JsonConvert.DeserializeObject<MyViewerStatsFormat>(tmpfile);
//otherstuff
}
catch(Exception ex)
{
//error loging stuff
}
Now on this line comes up the exception as follows:
{"Unexpected character encountered while parsing value: e. Path '', line 0, position 0."}
Does anyone have any solution on it?