How to Deserializing JSON to .NET object using Newtonsoft json in C# and pick only one value from the array?

CsharpServer Side ProgrammingProgramming

The WebClient class provides common methods for sending data to or receiving data from any local, intranet, or Internet resource identified by a URI.

The WebClient class uses the WebRequest class to provide access to resources. WebClient instances can access data with any WebRequest descendant registered with the WebRequest.RegisterPrefix method.

DownloadString Downloads a String from a resource and returns a String.

If your request requires an optional header, you must add the header to the Headers collection


  • In the below example we are calling the url ""

  • The example is then deserialized to User array

  • From the user array we are printing the first array value


class Program{
   static void Main(string[] args){
      var client = new WebClient();
      var json = client.DownloadString("");
      var userPosts = JsonConvert.DeserializeObject<User[]>(json);
public class User{
   public string userId { get; set; }
   public string id { get; set; }
   public string title { get; set; }
   public string body { get; set; }


sunt aut facere repellat provident occaecati excepturi optio reprehenderit
Published on 05-Nov-2020 13:42:05