Reputation: 13
I am currently working on a application which will give flash card like questions which I have stored on the system. I was wondering what would be my best option to store lists of information. The formatting I am currently using is where the first line is the question, next line is the correct answer and all subsequent lines are distractors, this being accomplished through file.read and write. The problem I have with this is that I cant use special symbols, like say I wanted to write NH4+, I would have to write it as NH4+.
So far I have looked into SQL lite and JSON, but neither seam to work, any advice is appreciated.
I cant seam to get txt files to properly return Unicode values and they feel almost clunky to use. with that I am unsure how to get Winforms to read and properly display Unicode either
Upvotes: 1
Views: 135
Reputation: 7111
{
"fractions": [
"2½",
"4¾"
],
"chemistry": [
"NH₄",
"H₂SO₄",
"³He"
],
"cards": [
"A♠",
"2♥",
"10♢",
"J♧"
]
}
textBox1
and textBox2
by default)private void Form1_Load(object sender, EventArgs e)
{
var json = File.ReadAllText("text.json");
textBox1.Text = json;
var data = JsonConvert.DeserializeObject<Dictionary<string, string[]>>(json);
var buffer = new StringBuilder();
foreach (var topLevel in data)
{
buffer.AppendLine(topLevel.Key);
foreach (var item in topLevel.Value)
{
buffer.AppendLine($" {item}");
}
}
textBox2.Text = buffer.ToString();
}
textBox1
:{
"fractions": [
"2½",
"4¾"
],
"chemistry": [
"NH₄",
"H₂SO₄",
"³He"
],
"cards": [
"A♠",
"2♥",
"10♢",
"J♧"
]
}
textBox2
fractions
2½
4¾
chemistry
NH₄
H₂SO₄
³He
cards
A♠
2♥
10♢
J♧
Is your issue more complicated than this? This worked the first time - I did no magic to get it to Just Work
Upvotes: 1