Simple XML to JSON and JSON to XML

Apr 7, 2009 at 5:47 AM
I really need some help on this. I am under a deadline. I am looking to preform a simple XML to JSON conversation. I thought that Json.NET would provide this but I see to have some issues.

My code is as follows.


        string sUrl = "C:\\Inetpub\\wwwroot\\asklaila - Events(Hyderabad).xml";
        StreamReader re = File.OpenText(sUrl);
        string input = null;
        while ((input = re.ReadLine()) != null)
        {
            Console.WriteLine(input);
        }

        JsonSerializer jsoncon = new JsonSerializer();
        JsonReader jread = new JsonReader(re);
        re.Close();


jread is null. What am I doing wrong? I just need a simple translation from wither end.The same hting happens when I feed it the content from a Stream that I recieved frmo a URL call.

Thanks in advance.
Michael
Coordinator
Apr 8, 2009 at 5:17 AM
Edited Apr 8, 2009 at 5:23 AM
http://www.google.com/search?q=json.net+xml
Apr 8, 2009 at 4:38 PM
James,

Thanks. I am following the example but and still having issues.

In my program I am reading in
http://api.yelp.com/business_review_search?term=yelp&tl_lat=37.9&tl_long=-122.5&br_lat=37.788022&br_long=-122.399797&num_biz_requested=3&ywsid=WuWVEa9BX4ITePrEnJ1euA

By Calling this is a browser it returns valid JSONbut I am still getting the error. My Code is as follows.
 
        XmlDocument xmlDoc = new XmlDocument();
       string sUrl = HttpGet("http://api.yelp.com/business_review_search?term=yelp&tl_lat=37.9&tl_long=-122.5&br_lat=37.788022&br_long=-122.399797&num_biz_requested=3&ywsid=WuWVEa9BX4ITePrEnJ1euA"); // Reads in Response Stream
        xmlDoc = (XmlDocument)JavaScriptConvert.DeerializeXmlNode(sUrl);
        Response.Write(xmlDoc.InnerText);

What am I doing wrong?

Thanks in advance.

Michael