The most important thing you need to do is prepopulate your string array with values. You can do this with the constructor to your class, like so:
public class User
{
[JsonProperty("username")]
public string Username { get; set; }
[JsonProperty("client-progresses")]
public string[] ClientProgresses { get; set; }
public User(int customerCount, string defaultState)
{
List<string> clientProgresses = new List<string>();
for (int i = 0; i < customerCount; i++)
{
clientProgresses.Add(defaultState);
}
ClientProgresses = clientProgresses.ToArray();
}
}
This way, when you construct your user, you pass in both the number of clients you want to initialize, and the default progress state for those clients, like so:
var user = new User(20, "init");
So that when you call your SaveProgress routine, you can test to see if the client exists before you update the value in the array, like so:
if (clientNumber >= user.ClientProgresses.Length)
{
throw new Exception($"Client number '{clientNumber}' is outside the range of the user client progress array '{user.ClientProgresses.Length}'");
}