久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='MiOfO'></tfoot>

  1. <legend id='MiOfO'><style id='MiOfO'><dir id='MiOfO'><q id='MiOfO'></q></dir></style></legend>
    <i id='MiOfO'><tr id='MiOfO'><dt id='MiOfO'><q id='MiOfO'><span id='MiOfO'><b id='MiOfO'><form id='MiOfO'><ins id='MiOfO'></ins><ul id='MiOfO'></ul><sub id='MiOfO'></sub></form><legend id='MiOfO'></legend><bdo id='MiOfO'><pre id='MiOfO'><center id='MiOfO'></center></pre></bdo></b><th id='MiOfO'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='MiOfO'><tfoot id='MiOfO'></tfoot><dl id='MiOfO'><fieldset id='MiOfO'></fieldset></dl></div>
    • <bdo id='MiOfO'></bdo><ul id='MiOfO'></ul>

  2. <small id='MiOfO'></small><noframes id='MiOfO'>

      json.net 不序列化派生類的屬性

      json.net does not serialize properties from derived class(json.net 不序列化派生類的屬性)

          • <bdo id='I4GMS'></bdo><ul id='I4GMS'></ul>

                <small id='I4GMS'></small><noframes id='I4GMS'>

                <legend id='I4GMS'><style id='I4GMS'><dir id='I4GMS'><q id='I4GMS'></q></dir></style></legend>

                <i id='I4GMS'><tr id='I4GMS'><dt id='I4GMS'><q id='I4GMS'><span id='I4GMS'><b id='I4GMS'><form id='I4GMS'><ins id='I4GMS'></ins><ul id='I4GMS'></ul><sub id='I4GMS'></sub></form><legend id='I4GMS'></legend><bdo id='I4GMS'><pre id='I4GMS'><center id='I4GMS'></center></pre></bdo></b><th id='I4GMS'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='I4GMS'><tfoot id='I4GMS'></tfoot><dl id='I4GMS'><fieldset id='I4GMS'></fieldset></dl></div>
                <tfoot id='I4GMS'></tfoot>
                  <tbody id='I4GMS'></tbody>
                本文介紹了json.net 不序列化派生類的屬性的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在使用 JSON.NET 6.0.1.當我使用 SerializeObject 方法序列化派生類的對象時,它僅序列化基類的屬性.以下是代碼片段:

                I'm using JSON.NET 6.0.1. When I use the SerializeObject method to serialize an object of my derived class, it serializes properties from base class only. Here is the code snippet:

                string v = JsonConvert.SerializeObject(
                                service, 
                                Formatting.Indented, 
                                new JsonSerializerSettings()
                                {
                                    TypeNameHandling = TypeNameHandling.All
                                });
                

                基類:

                [DataContract]
                public abstract partial class DataEntity : IDataEntity, INotifyPropertyChanging, INotifyPropertyChanged
                {
                    ...
                }
                

                派生類:

                [Table(Name = "dbo.mytable")]
                public sealed class mytable : DataEntity
                {
                    ...
                }
                

                我錯過了什么嗎?

                推薦答案

                是的,您缺少派生類的 [DataContract] 屬性.您還需要將 [DataMember] 添加到您想要序列化的任何屬性或字段(如果您尚未添加它們).Json.Net 在 5.0 版本 1 中進行了更改(4 月2013)這樣 [DataContract] 屬性不會被繼承.

                Yes, you are missing the [DataContract] attribute on the derived class. You also need to add [DataMember] to any properties or fields that you want serialized, if you haven't already added them. Json.Net was changed in version 5.0 release 1 (April 2013) such that the [DataContract] attribute is not inherited.

                請注意,如果您從您的類中刪除所有 [DataContract][DataMemeber] 實例,Json.Net 的行為會有所不同:在在這種情況下,Json.Net 的默認行為是序列化所有公共屬性,包括基類和派生類.

                Note that if you remove all instances of [DataContract] and [DataMemeber] from your classes, Json.Net behaves differently: in that case, the default behavior is for Json.Net to serialize all public properties, both in the base and derived classes.

                這篇關于json.net 不序列化派生類的屬性的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Ignore whitespace while reading XML(讀取 XML 時忽略空格)
                XML to LINQ with Checking Null Elements(帶有檢查空元素的 XML 到 LINQ)
                Reading XML with unclosed tags in C#(在 C# 中讀取帶有未閉合標簽的 XML)
                Parsing tables, cells with Html agility in C#(在 C# 中使用 Html 敏捷性解析表格、單元格)
                delete element from xml using LINQ(使用 LINQ 從 xml 中刪除元素)
                Parse malformed XML(解析格式錯誤的 XML)
                  <tbody id='xDzJO'></tbody>

                  <tfoot id='xDzJO'></tfoot>
                      <legend id='xDzJO'><style id='xDzJO'><dir id='xDzJO'><q id='xDzJO'></q></dir></style></legend>
                        <bdo id='xDzJO'></bdo><ul id='xDzJO'></ul>

                        <small id='xDzJO'></small><noframes id='xDzJO'>

                        <i id='xDzJO'><tr id='xDzJO'><dt id='xDzJO'><q id='xDzJO'><span id='xDzJO'><b id='xDzJO'><form id='xDzJO'><ins id='xDzJO'></ins><ul id='xDzJO'></ul><sub id='xDzJO'></sub></form><legend id='xDzJO'></legend><bdo id='xDzJO'><pre id='xDzJO'><center id='xDzJO'></center></pre></bdo></b><th id='xDzJO'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xDzJO'><tfoot id='xDzJO'></tfoot><dl id='xDzJO'><fieldset id='xDzJO'></fieldset></dl></div>
                          主站蜘蛛池模板: 国产视频一区二区在线观看 | 黄色大片在线播放 | 在线观看深夜视频 | 射欧美 | 久久久国产一区二区三区 | 久久艹免费视频 | 日本不卡一区二区三区在线观看 | 欧美午夜精品 | 伊人看片 | 精品无码久久久久久国产 | 一级毛片免费完整视频 | 成人精品一区二区三区中文字幕 | 国内成人免费视频 | 久久国产精品免费 | 日韩视频中文字幕 | 国产成人免费视频网站高清观看视频 | 国产欧美一区二区三区另类精品 | 一区二区精品 | 日韩三区在线观看 | 欧美自拍网站 | 密色视频 | 欧美日韩成人 | 久久九七| 久久久久久久久91 | 午夜三级视频 | 2022国产精品 | 亚洲欧美视频一区 | 久久国产欧美日韩精品 | 国产伦精品一区二区三区高清 | 夜夜精品浪潮av一区二区三区 | 中文字幕不卡在线观看 | 337p日本欧洲亚洲大胆精蜜臀 | 国产免费一级一级 | 在线观看日韩精品视频 | 日韩在线国产精品 | 欧美大片一区二区 | 久久久高清 | 狠狠插狠狠操 | 国产精品自产拍在线观看蜜 | 小视频你懂得 | 久久久免费电影 |