CSharp · Console
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
public class Program
{
public static void Main()
{
string jsonString = @"
{
""name"": ""Placeholder"",
""entries"":
[
{
""playerId"": ""27271906"",
""playerName"": ""Billy""
},
{
""playerId"": ""35568613"",
""playerName"": ""Jeeves""
}
]
}";
var result = JsonConvert.DeserializeObject<Top>(jsonString);
List<string> pros = new List<string>();
int i = 1;
foreach (IDs x in result.entries)
{
pros.Add(x.playerId);
i++;
if (i == 3)
{
break;
}
}
foreach (var pro in pros)
{
Console.WriteLine(pro);
}
}
}
public class IDs
{
public string playerId { get; set; }
}
public class Top
{
public List<IDs> entries { get; set; }
}