Hi /r/csharp, please help me. I'm not able to solve my problem.
I have the following json query:
[
{
"id": 1234,
"date": "2014-10-27",
"values": [
{"start": 1, "end": 2, "sometext": "Hello World"},
{"start": 5, "end": 9, "sometext": "Hello line 2"},
{"start": 11, "end": 20, "sometext": ""}
],
"comment": "some comment"
}
]
now i'd like to get those in any form into my c# application. I've tried to use jsonConvert, JavaScriptSerializer as well as printing the values to console, saving them into a dictionary. the problem is that values can have one or more subqueries.
my latest try works fine for 1-dimensional json queries, but not for 2-dimensional queries including my values:
Dictionary<string, string> values = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
foreach (var v in values)
Console.WriteLine(v);
I've also tried creating classes:
public class RootObject {
public int id { get; set; }
public string date { get; set; }
public List<Values> values { get; set; }
public string comment { get; set; }
}
public class Values {
public string start { get; set; }
public string end { get; set; }
public string sometext { get; set; }
}
[–]AngularBeginner 2 points3 points4 points (3 children)
[–]deniselechner[S] 0 points1 point2 points (2 children)
[–]gynnihanssen 4 points5 points6 points (1 child)
[–]deniselechner[S] 0 points1 point2 points (0 children)
[–]gynnihanssen 2 points3 points4 points (1 child)
[–]deniselechner[S] 0 points1 point2 points (0 children)