IfHow to install
Install-Package Newtonsoft.Json:
In Visual Studio, Tools menu -> Manage Nuget Package Manger Solution and type “JSON.NET” to search it online. Here's the figure:
Then create class with input parameters that you needexpect to get items from theit as a JSON object, I would use Jsonresponse.NET's LINQ
public class Inputs
{
public string input1 { get; set; }
public string input2 { get; set; }
public string input3 { get; set; }
public string input4 { get; set; }
}
Now we will convert it to JSON JObjecta .NET object using DeserializeObject() method of JsonConvert class. For exampleHere is the code:
JToken tokenprivate =void JObject.ParseJSONDeserilaize(stringFullOfJsonstring json);
int{
page = (int)token.SelectToken("page");
int totalPagesvar obj = (int)tokenJsonConvert.SelectTokenDeserializeObject<Inputs>("total_pages"json);
}
I like this approach because you don't need to fully deserialize the JSON object. This comes in handy with APIs that can sometimes surpriseNow you with missinghave an object properties, like Twitter.
Documentation: Serializing and Deserializing JSON with Json.NET and LINQ to JSON with Json.NETof type Inputs Deserialized successfully
