I’m working on a C# program that needs to fetch the most recent follower data from the Twitch API endpoint. The API returns JSON data with follower details, and I specifically need to extract the username field from this response.
I’ve already figured out how to write text data to a file, but I’m struggling with parsing the JSON response to get the specific field I need. I have Newtonsoft.Json installed in my project, but I can’t seem to get the parsing part working correctly.
Here’s a simple example of what I’m trying to achieve:
using System;
using System.Net.Http;
using System.IO;
using Newtonsoft.Json;
class Program
{
static async Task Main()
{
string apiUrl = "api-endpoint-here";
HttpClient client = new HttpClient();
string jsonResponse = await client.GetStringAsync(apiUrl);
// Need help parsing jsonResponse to get username
// Then save to file
}
}
Any guidance on how to properly deserialize the JSON and extract the follower name would be really helpful.