How do I deserialize JSON in C# with Newtonsoft

First, define your GetConfig function as:

public JObject GetConfig()
{
    return JObject.Parse(File.ReadAllText("path/config.json"));
}

then, call that function and access elements defined in the json file like:

JObject config = GetConfig();
string host = config.SelectToken("host").Value<string>();
string key = config.SelectToken("key").Value<string>();

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top