Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6332189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:12:52+00:00 2026-05-24T18:12:52+00:00

I have an action returning a simple JSON. For demonstration purposes, I will paste

  • 0

I have an action returning a simple JSON. For demonstration purposes, I will paste the sample code. Simple class to serialize:

public class Employee
{
    public string FullName { get; set; }
}

The action which returns the json:

public JsonResult Test()
{
    var employee = new Employee { FullName = "Homer Simpson" };
    var serializer = new JavaScriptSerializer();
    var json = serializer.Serialize(employee);

    return Json(json, JsonRequestBehavior.AllowGet);
}

Here is where I am confused. When I call this action from the browser and look at the response with Fiddler, this is the result:

HTTP/1.1 200 OK
Server: ASP.NET Development Server/10.0.0.0
Date: Mon, 15 Aug 2011 20:52:34 GMT
X-AspNet-Version: 4.0.30319
X-AspNetMvc-Version: 3.0
Cache-Control: private
Content-Type: application/json; charset=utf-8
Content-Length: 34
Connection: Close

"{\"FullName\":\"Homer Simpson\"}"

The “JSON” tab in Fiddler reads “The selected-response does not contain valid JSON text”.
The valid response should be like this:

"{"FullName":"Homer Simpson"}"

What is going on here?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:12:53+00:00Added an answer on May 24, 2026 at 6:12 pm

    You don’t need to serialize into JSON yourself, this should do:

    public JsonResult Test() {
      var employee = new Employee { FullName = "Homer Simpson" };
      return Json(employee, JsonRequestBehavior.AllowGet);
    }
    

    Your code effectively serializes it twice, which gives you a string result.

    The valid response should actually be this:

    {"FullName":"Homer Simpson"}
    

    (without the surrounding quotes)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an action like this: public class News : System.Web.Mvc.Controller { public ActionResult
I have an action method returning a JsonResult in my controller: public JsonResult GetDetails()
I have a jqGrid calling a controller action (returning JSON to jqGrid). When my
I have a Struts 2 action returning a JSON result. {columns:[coupon,CM,CM+1,CM+2,CM+3],couponList:[{coupon:3.0,CM:88.2323,CM+1:89.45,CM+2:132.3128125,CM+3:32.82},{coupon:3.5,CM:25,CM+1:3125,CM+2:333,CM+3:5}],Caption:30 Yr Fixed} I
I have created a simple repository class that is returning a list of Projects:
I have the following domain class: public class Product { public virtual Guid Id
I have an Action Method that I'd either like to return JSON from on
I have a simple url that will toggle one field in my search model.
I have a code like this <html> <head>Title <script> function callme() { alert(Hi); document.test.action
I currently have a simple MVC RedirectToAction action: return RedirectToAction(Edit, Customers, new {Id =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.