taskeenkayani / ext-direct-mvc

Automatically exported from code.google.com/p/ext-direct-mvc
0 stars 0 forks source link

Enhancement for formatted Json response in debug mode #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello Eugene, thanks for the awesome library.  It has come in very handy!

I wanted the ability to see nicely formatted responses in the Firebug
console while debugging, so I made a little mod that does just that.  In 
DirectResponseBase.ToJson() I simply changed:

            using (var writer = new StringWriter()) {
                serializer.Serialize(writer, this);
                jsonResponse = writer.ToString();
            }

to:

            var sw = new StringWriter();
            using (JsonWriter jsonWriter = new JsonTextWriter(sw)) {
                jsonWriter.Formatting = DirectConfig.Debug ?
Formatting.Indented : Formatting.None;
                serializer.Serialize(jsonWriter, this);
                jsonResponse = sw.ToString();
            }

Works perfectly and uses the web.config debug value to control formatting.
 Hopefully you'll also find it useful and maybe add it!

Thanks again.

Original issue reported on code.google.com by bmoes...@gmail.com on 16 Mar 2010 at 5:39

GoogleCodeExporter commented 8 years ago
Thanks Brian. Added. See r54.

Original comment by elishnevsky on 16 Apr 2010 at 6:08

GoogleCodeExporter commented 8 years ago
Issue 6 has been merged into this issue.

Original comment by elishnevsky on 16 Apr 2010 at 6:12