The most likely issue is that the response is on multiple lines, but you're only reading the first line.
Either change your code to read the entire response, using
ReadToEnd
instead of
ReadLine
:
using (var client = new WebClient())
using (var stream = client.OpenRead(sURL))
using (var reader = new StreamReader(stream))
{
var jObject = Newtonsoft.Json.Linq.JObject.Parse(reader.ReadToEnd());
Console.WriteLine((string)jObject["results"][0]["vicinity"]);
}
Or use a
JsonReader
to load the data:
using (var client = new WebClient())
using (var stream = client.OpenRead(sURL))
using (var reader = new StreamReader(stream))
using (var json = new JsonTextReader(reader))
{
var jObject = Newtonsoft.Json.Linq.JObject.Load(json);
Console.WriteLine((string)jObject["results"][0]["vicinity"]);
}