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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:05:54+00:00 2026-06-05T04:05:54+00:00

I am trying to determine how to exclude __type in my JSON response from

  • 0

I am trying to determine how to exclude __type in my JSON response from an asmx WebService.

The class that I am returning is constructed as follows.

public class MyClassName
{
    private string _item1 = string.Empty;
    private string _item2 = string.Empty;

    public string item1 = { get { return _item1; } set { _item1 = value; } }
    public string item2 = { get { return _item2; } set { _item2 = value; } }
}

public class MyClassName_List : List<MyClassName>
{
    public MyClassName_List() {}
}

I then have a Data Access Layer and Business Logic Layer that returns a populated instance of MyClassName_List. My WebMethod is setup as follows.

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class MyClassName_WebService : System.Web.Services.WebService
{
    [WebMethod]
    public MyClassName_List GetList()
    {
        return MyClassName_List_BusinessLogicLayer.GetList();
    }
}

The JSON object return is structured as follows.

[
    {
    item1: "item1-1 text",
    item2: "item1-2 text",
    __type: "NamespaceUsed.MyClassName"
    },
    {
    item1: "item2-1 text",
    item2: "item2-2 text",
    __type: "NamespaceUsed.MyClassName"
    },
]

I just want to return the JSON object as follows.

[
    {
    item1: "item1-1 text",
    item2: "item1-2 text"
    },
    {
    item1: "item2-1 text",
    item2: "item2-2 text"
    }
]

I have tried the suggestions from here, but I can not seem to implement it properly. Any help on this is much appreciated!

  • 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-05T04:05:55+00:00Added an answer on June 5, 2026 at 4:05 am

    The way to do this is follows.

    public class MyClassName
    {
        private string _item1 = string.Empty;
        private string _item2 = string.Empty;
    
        public string item1 = { get { return _item1; } set { _item1 = value; } }
        public string item2 = { get { return _item2; } set { _item2 = value; } }
    
        protected internal MyClassName() { } //add a protected internal constructor to remove the returned __type attribute in the JSON response
    }
    
    public class MyClassName_List : List<MyClassName>
    {
        public MyClassName_List() {}
    }
    

    I hope this helps someone else too!

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

Sidebar

Related Questions

I'm trying determine if it's possible in C# to have a generic class that
I'm trying to determine how to access the data that is in my JObject
I have forms posting data from instances of a particular abstract class: public abstract
I'm trying to determine the relationship between default values and the has_foo() methods that
I am trying to determine the class type of a class using reflection and
Im trying to determine where a shot will hit the wall from a position
I'm trying to determine whether or not a expression passed into my Expressions class
Am trying to determine the best way to persist information from an originating email,
I'm trying to determine if there is a way that I can count percentage
I am trying to determine the figure number contained to the current chapter from

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.