jsonfx/jsonfx — Issue #19: Failure when reading directly from HTTP stream + StreamReader
Author: JornWildt
Created: 2012-02-09 06:53:30+00:00
State: open

The following code works as expected (showing "Number of tweets = 2") when reading the input into a string before parsing. When the StreamReader is used directly it fails with "Unterminated JSON string".

JsonFx version 2.0.1106.2515

Bug or feature? Am I doing something wrong?

static void JsonReadFailure()
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.twitter.com/1/statuses/user_timeline.json?screen_name=JornWildt&count=2");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

JsonReader jsr = new JsonReader();
using (TextReader reader = new StreamReader(response.GetResponseStream()))
{
#if true
dynamic result = jsr.Read(reader);
#else
string json = reader.ReadToEnd();
dynamic result = jsr.Read(json);
#endif

Console.WriteLine("Number of tweets = {0}.", result.Length);
}
}