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

  • Home
  • SEARCH
  • 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 6851099
In Process

The Archive Base Latest Questions

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

I am a little confused about when do I have to serialize objects using

  • 0

I am a little confused about when do I have to serialize objects using JSON serialization and when it is not necessary (even needless).

I’ve spent several days trying to send a list of simple objects using jQuery.ajax and JSON.
I have a class named Product:

public class Product
{
    public string Name;
    public string Qnt;
    public string Price;
}

and a web method that returns a list filled with Products

List<Product> p = new List<Product>();

I used System.Web.Script.Serialization.JavaScriptSerializer to serialize this list in JSON and send it to the client as a string, where i format it using jQuery

$.each(msg.d, function (index, Product) {
    $('#details').append('<p>Name: ' + Product.Name 
                           + '<br />Quantity: ' + Product.Qnt 
                           + '<br />Price: ' + Product.Price + '</p>');
});

…and it wouldn’t work… Because at the client side, I just get a long string (it would be parsed character by character, when I use $.each) – I learned that it should be parsed first

It took time until I realised that I just have to return it as a List of Product objects, without serialization, and client gets list of products in perfect JSON format!

EDIT:
What I actually don’t understand: if I serialize my list, it returns JSON formated string that have to be parsed before I can use it. If i don’t serialize my list, it returns the same data, but as an object, not a string, so I can use it right away. How can I know do I have to use JSON serialization on my data, or it will always be done by framework?

  • 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-27T01:12:24+00:00Added an answer on May 27, 2026 at 1:12 am

    You’re not returning your List<Product> directly to the client. It’s not going over the wire as a List<Product> – there’s no such concept at the HTTP level. However, the server-side framework you’re using is performing the JSON serialization for you. If you perform serialization first, then the serialized string will then be JSON-serialized, including another level of escaping etc.

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

Sidebar

Related Questions

I am a little confused about the auto-increment id field in rails. I have
I'm a little confused about using release vs. debug versions of a dll for
I'm a little confused about how EGit workes. I have an existing git repository
I a little confused about how this work even if it works properly. I
I'm a little confused about how C++ handles includes. I have something like: typedef
I'm a little confused about the distinction between mutable and immutable objects. I tried
I'm a little confused about egg files and installing them using easy_install, hope you
I'm a little confused about the best practice to achieve the following: I have
I'm a little confused about the Swing painting model. Suppose that I have a
I have 2 lists and am a little confused about adding an object into

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.