I get a json response after making a query to an api.
The JSON is like:
{
\"results\": [
{
\"alternatives\": [
{
You should deserialize this. It's the easiest way to deal with it. Using Json.NET and dynamic
that might look like:
dynamic jsonObj = JsonConvert.DeserializeObject(responseFromServer);
foreach (var result in jsonObj.results) {
foreach (var alternative in result.alternatives) {
Console.WriteLine(alternative.transcript);
}
}
But you might want to make explicit classes for it instead. Then you can do:
MyRootObject root = JsonConvert.DeserializeObject(responseFromServer);
And deal with it like any other .NET object.