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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:05:58+00:00 2026-05-19T22:05:58+00:00

I noticed that with the DataContractJsonSerializer the serialized JSON string sometimes include the type

  • 0

I noticed that with the DataContractJsonSerializer the serialized JSON string sometimes include the type information in the form of

{"__type":"MyClass:#MyNamespace", ... }

based on my observations it seems to only do this when it’s serializing a base type but a known sub type is passed instead which makes sense, but I haven’t found any official documentations to confirm this or indeed anyway to force the serializer to consistently exhibit this behaviour whenever it encounters a custom type.

Can anyone confirm if my observations are correct? Better yet, if you know of a way to instruct the serializer to always serialize the type information for custom types, if this is at all possible?

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-19T22:05:59+00:00Added an answer on May 19, 2026 at 10:05 pm

    Actually, you CAN force the serializer to always consistently emit __type information.

    If you are using the serializer standalone, use the constructor overload that takes the “alwaysEmitTypeInformation” argument. Pass in true.

    If you are using DataContractJsonSerializerOperationBehavior, set the same property on that attribute to true. I believe you can also do it via config.

    Finally, see the section “When Are Type Hints Emitted” at http://msdn.microsoft.com/en-us/library/bb412170.aspx for a more detailed explanation.

    Hope this helps!

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

Sidebar

Related Questions

I noticed that scala.xml.Atom takes a type parameter A , even though all of
I noticed that interface type definition metadata looks like: TypDefName: Interfaces.IMyInterface (02000003) Flags :
I noticed that there are two debug perspectives in Eclipse that is setup for
I noticed that the SimpleFTPSample that apple provides leaks memory. The Leaks Performance tool
I noticed that if you copy-paste web browser content into Notepad (or any text
I noticed that some of my gzip decoding code seemed to be failing to
I noticed that in my application, most compatibility problems were caused by 'access denied'
I noticed that I can extend a class and at the same time pass
I noticed that when I test my app on the iPad 3.2 software, my
I noticed that I can place subview outside of superview's bound (either partly or

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.