0

I am trying to parse JSON data from this API:

I wrote that on Main Form:

void button1_Click(object sender, EventArgs e)
{
    using (var webClient = new System.Net.WebClient())
    {
        var json = webClient.DownloadString("URL");
        var user = JsonConvert.DeserializeObject<User>(json);
        MessageBox.Show(User.callsign);
    }
}

And I created a class where I convert JSON data to strings with JSONProperty:

public class User
{
    [JsonProperty("callsign")]
    public string callsign { get; set; }
}

The problem is that when I try the MessageBox.Show(user.callsign) on the main form, I can´t. Because the button1 void is static and the callsign string is not. What can I do??

Regards!!

2
  • Do not vandalize your own posts. Commented Sep 5, 2015 at 21:25
  • Is not vandalizing them. I wanted to delete the URL of the API, and I made a mistake :( Commented Sep 5, 2015 at 21:28

1 Answer 1

2

You are using the Class name and not the variable name. C# is case sensitive.

Change it to this:

MessageBox.Show(user.callsign);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.