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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:09:36+00:00 2026-06-11T16:09:36+00:00

I have a Responsiblity class, which contains some subclasses Below is the class:- public

  • 0

I have a Responsiblity class, which contains some subclasses
Below is the class:-

public class Responsibility
{
    private Frequency _FrequencyInfo = new Frequency();
    private ResponsibilityCategory _CategoryInfo = new ResponsibilityCategory();
    private Status _StatusInfo = new Status();

    public int ResponsibilityId { get; set; }
    public string ResponsibilityName { get; set; }
    public string Description { get; set; }
    public Frequency FrequencyInfo
    {
        get { return _FrequencyInfo; }
        set { _FrequencyInfo = value; }
    }
    public ResponsibilityCategory CategoryInfo
    {
        get { return _CategoryInfo; }
        set { _CategoryInfo = value; }
    }
    public Status StatusInfo
    {
        get { return _StatusInfo; }
        set { _StatusInfo = value; }
    }
}

Below is the code i am using to bind the list.But i am getting all the elements of the class.
I just wants two elements from the class.

Responsibility newResponsibilty = new Responsibility();
        newResponsibilty.ResponsibilityId = ResponsibilityId;
        new iNGRID_Data.Ops.DataMethods().dbrGetResponsibilityDetailsInSpecifiedResponsibilty(ref newResponsibilty, ResponsibilityId, ref err);
        List<Responsibility> listResponsibilty = new List<Responsibility>();
        listResponsibilty.Add(newResponsibilty);

        JavaScriptSerializer jsonserialize = new JavaScriptSerializer();
        string result = jsonserialize.Serialize(listResponsibilty);
        return Content(result);

I want to serialize this list with just 2 objects ResponsibiltyName and Description.
Please suggest.

  • 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-11T16:09:37+00:00Added an answer on June 11, 2026 at 4:09 pm

    Don’t manually JSON serialize them. Leave it to the framework by returning a Json result. Also you don;t need a list. You could return an anonymous object containing the properties you are interested in:

    public ActionResult SomeAction()
    {
        Responsibility newResponsibilty = new Responsibility();
        newResponsibilty.ResponsibilityId = ResponsibilityId;
        new iNGRID_Data.Ops.DataMethods().dbrGetResponsibilityDetailsInSpecifiedResponsibilty(ref newResponsibilty, ResponsibilityId, ref err);
        var result = new
        {
            name = newResponsibilty.ResponsibiltyName, 
            description = newResponsibilty.Description
        };
        return Json(result, JsonRequestBehavior.AllowGet);
    }
    

    and inside your AJAX success callback you could read those properties:

    success: function(result) {
        // you could use result.name and result.description here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class which has a well-defined responsibility - to Enrich an object
I have a class on which I am overloading new and delete (these fetch
For my understanding purpose i have implemented Chain-Of-Responsibility pattern. //Abstract Base Type public abstract
have written this little class, which generates a UUID every time an object of
So say I have a class like this: class A { public: A( SomeHugeClass*
Let's say you have abstract class A doing some stuff. Then you have abstract
I have a pretty complex class which extends System.Windows.Forms.UserControl . It's written in C++/CLI
I have a LINQ partial class: public partial class resp { public IEnumerable<RuleViolation> GetRuleViolations()
I want to have a collection of objects, which will be of a class
I have YoutubeVideoService class which does CRUD(Create, Read, Update, and Delete) operations. In my

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.