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 8564535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:13:21+00:00 2026-06-11T17:13:21+00:00

So i send an Json object to my server, and i want to convert

  • 0

So i send an Json object to my server, and i want to convert it to a strongly typed user type object that i have called PersonalPreferences.

Here is the JS

{
"PersonalPreferences": [
    {
        "FavoriteFood": "Pasta with butter and cheese"
    },
    {
        "FavoriteSport": "Submission Wrestling"
    },
    {
        "FavoriteGame": "Starcraft 2"
    },
    {
        "FavoriteMusic": "Hip Hop"
    }
]
}

I have created a Class that matches the Json object i am sending.

    [DataContract]
public class PersonalPreferences
{
    [DataMember]
    public string FavoriteFood { get; set; }

    [DataMember]
    public string FavoriteSport { get; set; }

    [DataMember]
    public string FavoriteGame { get; set; }

    [DataMember]
    public string FavoriteMusic { get; set; }

    public PersonalPreferences()
    {
    }

    public PersonalPreferences(string favoriteFood, string favoriteGame, string favoriteMusic, string favoriteSport)
    {
        this.FavoriteFood = favoriteFood;
        this.FavoriteGame = favoriteGame;
        this.FavoriteMusic = FavoriteMusic;
        this.FavoriteSport = favoriteSport;

    }
}

And here is my handler that receives the Request and coverts it to the user type object.
My problem is that the PersonalPreference object is empty. The jsSerializer.Deserialize calls the empty constructor and the values from the Json object is not passed to the PersonalPreference object.
I have checked that the Json value exists in the Request as a string.

    [WebService(Namespace = "http://localhost:53243")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class JSonTestHandler : IHttpHandler, System.Web.SessionState.IReadOnlySessionState
{

    public void ProcessRequest(HttpContext context)
    {
        string jsonData = new StreamReader(context.Request.InputStream, System.Text.Encoding.UTF8).ReadToEnd();
        var jsSerializer = new JavaScriptSerializer();
        var personalPreferences = jsSerializer.Deserialize(jsonData, typeof(PersonalPreferences));
    }}
  • 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-06-11T17:13:22+00:00Added an answer on June 11, 2026 at 5:13 pm

    It seems some thing wrong with supplied json formatted string.
    if Check with following json formatted string it’s works fine:

    {“FavoriteFood”: “Pasta with butter and cheese”,”FavoriteSport”: “Submission Wrestling”,”FavoriteGame”: “Starcraft 2″,”FavoriteMusic”:
    “Hip Hop”}

    How did you generated the Json formatted string?

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

Sidebar

Related Questions

I'm trying to send JSON-object form MongoDB to page with ejs template engine. Here's
I want to send a JSON object from the client to an action on
I'm writing some code that will serialize a C# object to JSON, send it
I want to convert the html tag objects to json object in the javascript
I have following json data which I want to pass it to server using
i want to send json to server using Spring 3.x, i use annotation @RequestBody,
How can I convert the PHP variable in server side to the JSON object?
I want to convert personArray to a JSON string, and send a request to
I would like to send JSON post request to rails 3 server. I have
I have an MVC project that provides (GET) & consumes (PUT) a Json object.

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.