How do I tell DataContractJsonSerializer to not include the “__type” property

前端 未结 1 1126
甜味超标
甜味超标 2020-12-19 11:45

I need to add KnownType to the below code for it to serialize successfully. When I do, the generated JSON is as follows:

JSON form of Adult with 1 child: {\"         


        
相关标签:
1条回答
  • 2020-12-19 12:00

    As I told you in the last question, I don't know, but some research leads me to believe that the following might achieve what you want:

    var settings = new DataContractJsonSerializerSettings();
    settings.EmitTypeInformation = EmitTypeInformation.Never;
    
    var serializer = new DataContractJsonSerializer(yourType, settings);
    
    0 讨论(0)
提交回复
热议问题