Answer the question
In order to leave comments, you need to log in
How to get value from array to json?
Hello everyone
I saw a bunch of answers, but I tried everything and I can not get the value in any way !!!
There is a taco class:
public bool StartMessage { get; set; } = false;
public List<string> users = new List<string>();
public List<string> keys = new List<string>();
public List<string> blacklist = new List<string>();
public static void Save(Settings[] settings) => File.WriteAllText("settings.json", JsonConvert.SerializeObject(settings));
List<string> key = Console.ReadLine().Split(' ').ToList();
Settings[] settings = new Settings[]
{
new Settings
{
keys = key
}
};
Settings.Save(settings);
Answer the question
In order to leave comments, you need to log in
Decided!
var des = JsonConvert.DeserializeObject<List<Settings>>(File.ReadAllText("settings.json"));
foreach(string i in des[0].keys)
{
Console.WriteLine(i);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question