Sivakumar

Sivakumar

  • NA
  • 551
  • 218.5k

how to use json conversion in windows form application

Sep 11 2015 12:27 AM
Hi,
 
 
I want to use json convertion to return a values. but i don't no how to use 
 
This is my code :
 
public partial class Form1 : Form
{

string URI;
string email = ConfigurationSettings.AppSettings["email"].ToString();
string password = ConfigurationSettings.AppSettings["password"].ToString();

public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void submit_Click(object sender, EventArgs e)
{
URI = string.Concat(host_textbox.Text, api_textbox.Text);//textBox2.Text + textBox1.Text;

GetLogin();
}
#region Methods

private async void GetLogin()
{
using (var client = new HttpClient())
{

var login = new LoginData() { Email = email, Password =password };

var response = await client.PostAsJsonAsync(URI, login);


client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

if (response.IsSuccessStatusCode)
{

var productJsonString = await response.Content.ReadAsStringAsync();
body.Text = productJsonString;
}
}

}
}
#endregion

public class LoginData
{
public string Email { get; set; }

public string Password { get; set; }

}

 
So i want to return a values using json convertion
 
Please give me help
 
Thank you

Answers (1)