I'm trying to parse this Google calendar response I'm getting from their Rest API using c#, but I seem to keep getting stuck. [edited] Update, the @ symbol isn't preventing the drill down, I verified by replacing the @
with _at_
. See the screenshot of the Quick watch:
I'm sure I'm accessing this incorrectly...
Here's the jsonString
I'm trying to parse:
{
"kind": "calendar#freeBusy",
"timeMin": "2015-06-12T14:00:00.000Z",
"timeMax": "2015-06-14T14:00:00.000Z",
"calendars": {
"[email protected]": {
"busy": [
{
"start": "2015-06-13T18:30:00Z",
"end": "2015-06-13T19:30:00Z"
},
{
"start": "2015-06-13T20:30:00Z",
"end": "2015-06-13T21:30:00Z"
},
{
"start": "2015-06-13T23:00:00Z",
"end": "2015-06-14T00:00:00Z"
}
]
}
}
}
I've tried using:
dynamic myObj = Json.Decode(jsonString);
and
var myObj = JsonConvert.DeserializeObject(jsonString);
but I can't figure out how to get into the [email protected]
key (which is dynamic based on what I send up) to cycle through all the busy times.
Ideas?
You can access it via a string indexer:
var myObj = JsonConvert.DeserializeObject<dynamic>(jsonString);
Console.WriteLine(myObj.calendars["[email protected]"]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With