Sunday, October 13, 2013

Parsing Json using Jason.net in MVS 2008 C#, .net 3.5, linq



Based here
http://json.codeplex.com/
and here
http://james.newtonking.com/json/help/index.html?topic=html/ParseJsonObject.htm
and SO
http://stackoverflow.com/questions/9107216/print-select-value-from-json-object


here the code...
using (StreamReader sr = new StreamReader(txtfile))
  {
   String line = sr.ReadToEnd();
   //MessageBox.Show(line);
   JObject stuff = JObject.Parse(line);
   if (stuff != null)
   {
    //JToken response = stuff["results"]; //parsing response
    JArray venues = (JArray)stuff["results"];
    JValue names = (JValue)venues[0]["title"];
    MessageBox.Show(names.ToString());
   }
  }