Hello Stackers,
i have a json file and i want to get the values randomly and divide the result in two. the idea is to divide the list of 14 players on two means 7 players in each team and the selection must be randomly presented
Here is the Json file located in Models Folder
{
"Football": {
"Players": [
{
"id": "1",
"Name": "Gabriel"
},
{
"id": "2",
"Name": "Leozin"
},
{
"id": "3",
"Name": "Gustavinho"
},
{
"id": "4",
"Name": "Bira"
},
{
"id": "5",
"Name": "Alvin"
},
{
"id": "6",
"Name": "Sugar"
},
{
"id": "7",
"Name": "Donato"
},
{
"id": "8",
"Name": "Alessandro"
},
{
"id": "9",
"Name": "Kenji"
},
{
"id": "10",
"Name": "Kleber"
},
{
"id": "11",
"Name": "Lemão"
},
{
"id": "12",
"Name": "Jonatas"
},
{
"id": "13",
"Name": "Abdo"
},
{
"id": "14",
"Name": "Kleber"
}
]
}
}
Here is the Controller:
using System.Net.Http;
using System.Text;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
namespace MidasFootballApi.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
// GET api/values
[HttpGet]
public object Get()
{
string path = @"Models/Football.json";
string allText = System.IO.File.ReadAllText(path);
object jsonObject = JsonConvert.DeserializeObject(allText);
return jsonObject;
}
}
}
Any help will be appreciated