<p>I am using the FlexiGrid jQuery plug in and I need to get a JSON object back form my MVC App, simple enough if the FlexiGrid took just the object but I need to add a few items to the response string for it to work properly with FlexiGrid.</p>

<p>So here is a portion of my controller code:</p>

<pre><code>If Request.QueryString("json") IsNot Nothing Then
    Dim data As New StringBuilder()
    data.Append("page: " &amp; pageIndex &amp; "," &amp; vbCrLf)
    data.Append("total: " &amp; ViewData.TotalCount &amp; "," &amp; vbCrLf)
    data.Append("rows: ")
    data.Append(Json(objCustomerList))

    Return Content(data.ToString())
End If
</code></pre>

<p>Unfortunately in the above code <code>Json(objCustomerList)</code> returns 'System.Web.MVV.JsonResult' instead of the desired JSON string data.  I also tried <code>Json(objCustomerList).ToString()</code> just to see what would happen and the same thing again.</p>

<p>Any ideas?</p>

```
Json()
```
method in ASP.NET MVC is just using the
```
JavaScriptSerializer
```
class via the
```
JsonResult
```
class.  You could use that yourself if you wanted to serialize the objCustomerList object using JSON to a string.
My recommendation would be to take a slightly different approach.
Create a Model that represented the .NET equivalent of the JavaScript object you were trying to create.  Maybe a FlexiGridModel object with Page, Total, Rows, and CustomerList properties.
Then when you pass that FlexiGridModel to
```
Json()
```
it would just work, no need to build a JSON string using
```
StringBuilder
```
.
If you just want your code to work there is an
override on
```
JavaScriptSerializer.Serialize()
```
that takes the object to serialize and the
```
StringBuilder
```
to append the results to.  Which should be exactly what you are looking for.
Some relevant links:
JavaScriptSerializer example
ASP.NET MVC JsonResult source
Codeproject: ASP.NET MVC Flexigrid sample