<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>HttpHandlers and HttpModules</title><link>http://forums.asp.net/27.aspx</link><description>Extending the ASP.NET Framework through HttpModules and HttpHandlers.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Returned JSONproblem from JavascriptSerializer adds [ and ]</title><link>http://forums.asp.net/thread/3264694.aspx</link><pubDate>Mon, 29 Jun 2009 16:33:34 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3264694</guid><dc:creator>gunteman</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3264694.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=27&amp;PostID=3264694</wfw:commentRss><description>&lt;p&gt;[ and ] is proper JSON array notation. The problem is in your consuming code. &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Returned JSONproblem from JavascriptSerializer adds [ and ]</title><link>http://forums.asp.net/thread/3264658.aspx</link><pubDate>Mon, 29 Jun 2009 16:11:33 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3264658</guid><dc:creator>dba123</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3264658.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=27&amp;PostID=3264658</wfw:commentRss><description>&lt;p&gt;Currently I&amp;#39;m using the helper methods outlined here to return some JSON from my .ashx: http://weblogs.asp.net/scottgu/archive/2007/10/01/tip-trick-building-a-tojson-extension-method-using-net-3-5.aspx&lt;/p&gt;&lt;p&gt;Problem is, I get [ and ] wrapped around my JSON which is malformed..&lt;a href="http://docs.jquery.com/GetJSON"&gt;.jQuery cannot pick it up in the callback&lt;/a&gt;:&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;b&gt;[&lt;/b&gt;&lt;/span&gt;{&amp;quot;ImageTag&amp;quot;:&amp;quot;&amp;amp;lt;img src=&amp;amp;quot;http://www.xxx.com/image/473.jpg&amp;amp;quot; alt=&amp;amp;quot;&amp;amp;quot;&amp;amp;gt;&amp;quot;},{&amp;quot;ImageTag&amp;quot;:&amp;quot;&amp;amp;lt;img src=&amp;amp;quot;http://www.xxx.com/image/485.jpg&amp;amp;quot; alt=&amp;amp;quot;&amp;amp;quot;&amp;amp;gt;&amp;quot;}&lt;span&gt;&lt;b&gt;]&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;So I don&amp;#39;t know why I get brackets around this.&amp;nbsp; Here is my implementation:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;pre name="code" class="c-sharp"&gt;    private void GetImagesJSON(HttpContext context)
    {
        context.Response.ContentType = &amp;quot;text/plain&amp;quot;;
        context.Response.Charset = Encoding.UTF8.ToString();
        
        int i = 1;

        List&amp;lt;Product&amp;gt; products = GetTestProducts();
        List&amp;lt;CtImageList&amp;gt; imageList = new List&amp;lt;CtImageList&amp;gt;();
        
        foreach(Product p in products)
        {
            string imageTag = HttpUtility.HtmlEncode(string.Format(@&amp;quot;&amp;lt;img src=&amp;quot;&amp;quot;{0}&amp;quot;&amp;quot; alt=&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;gt;&amp;quot;, ImageUrl(p.Image, false)));
            
            imageList.Add(new CtImageList{ImageTag = imageTag});
            i++;
        }

        string jsonString = imageList.ToJSON();
        context.Response.Write(jsonString);
    }&lt;/pre&gt;&lt;br /&gt; &lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>