I wrote a class with fields. Then I need an init method to initialize the fields of the class. But it throws an error Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: C. Path '', line 0, position 0.
public class Valera
{
private int health;
private int mana;
private int happiness;
private int fatigue;
private bool dead;
public void init()
{
var v = JsonConvert.DeserializeObject<Valera>(@"C:\Users\User\RiderProjects\MarginalValera\MarginalValera\Properties\characteristics.json");
Console.WriteLine(v?.dead);
}
}
JSON object:
{
"health" : "100",
"mana": "50",
"happiness": "0",
"fatigue": "50",
"dead": "false"
}