try this
Create a class like this
public class ImdbEntity
{
public string Title { get; set; }
public string Year { get; set; }
public string Rated { get; set; }
public string Released { get; set; }
public string Runtime { get; set; }
public string Genre { get; set; }
public string Director { get; set; }
public string Writer { get; set; }
public string Actors { get; set; }
public string Plot { get; set; }
public string Language { get; set; }
public string Country { get; set; }
public string Awards { get; set; }
public string Poster { get; set; }
public string Metascore { get; set; }
public string imdbRating { get; set; }
public string imdbVotes { get; set; }
public string imdbID { get; set; }
public string Type { get; set; }
public string Response { get; set; }
}
use the below code to fill the values of the movie information into the respective text-boxes,
customize it based on your need.
private void btnSearch_Click(object sender, EventArgs e)
{
string url = "http://www.omdbapi.com/?t=" + txtMovieName.Text.Trim();
using (WebClient wc = new WebClient())
{
var json = wc.DownloadString(url);
JavaScriptSerializer oJS = new JavaScriptSerializer();
ImdbEntity obj = new ImdbEntity();
obj = oJS.Deserialize<ImdbEntity>(json);
if (obj.Response == "True")
{
txtActor.Text = obj.Actors;
txtDirector.Text = obj.Director;
txtYear.Text = obj.Year;
}
else
{
MessageBox.Show("Movie not Found!!!");
}
}
}
Note: Refer this dll (
System.Web.Extensions.dll
) to your project
using System.Web.Script.Serialization;