i have a json with some string data. json parsing and getting values are working fine but what i want to do is to concatenate between json values like below is my json data
{
"Addition": {
"Easy": [
"New York Bulls",
"Los Angeles Kings",
"Golden State Warriros",
"Huston Rocket",
"I have a problem.",
"What is the price of this cap?",
"Sorry, I was sick. I went to bed early.",
"I'll be back right away",
"This is my cousin.",
"I am not always at home on Sundays.",
"Tom suggested another plan to the committee.",
"I'll look in the living room.",
"I came here to see if there was something I could do to help",
"but there doesn't seem to be anything for me to do.",
"You have a very nice car.",
"John wanted to be completely independent of his family.",
"Mary is studying in her room.",
"He used to eat out every day, but now he can't afford it.",
"He introduced me to a pretty girl.",
"How many books does he have?",
"I'll pay.",
"You don't have to get up so early.",
"Do you like tennis?",
"Keep out.",
"Coach."
]
}
}
i want to do like this with my json data like in below list of strings i am concatenating values
var list = new List<string> { girl1names[GirlName] +" was playing
basketball. " + random.Next(min, max) + " of her shots went in the hoop.
" + random.Next(min, max) + " of her shots did not go in the hoop. How
many shots were there in total?"
so i just want to do this with my json data like this below
{
"Addition": {
"Easy": [
" girl1names[GirlName] + New York Bulls",
" random.Next(min, max) + Los Angeles Kings"
]
}
}
This the code where i am reading my json as a string then i call a for loop pick some random strings from the json and store that values in a wordproblemslist
using (var reader = new System.IO.StreamReader(streams))
{
string json = reader.ReadToEnd();
JObject jObject = JObject.Parse(json);
JToken jUser = jObject["Addition"];
var result = JsonConvert.DeserializeObject<RootObject>
(json);
List<string> lst = new List<string>();
for (int i = 0; i < result.Addition.Easy.Count; i++)
{
lst.Add(result.Addition.Easy[i]);
}
List<int> listNumbers = new List<int>();
int number;
for (int j = 0; j < questions; j++)
{
do
{
number = randoms.Next(lst.Count);
} while (listNumbers.Contains(number));
listNumbers.Add(number);
}
for (int k = 0; k < listNumbers.Count; k++)
{
wordproblemslist.Add(lst[listNumbers[k]]);
}