久久久久久久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 不序列化派生類的屬性的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我正在使用 JSON.NET 6.0.1.當(dāng)我使用 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 的默認(rèn)行為是序列化所有公共屬性,包括基類和派生類.

                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.

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

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

                相關(guān)文檔推薦

                Ignore whitespace while reading XML(讀取 XML 時忽略空格)
                XML to LINQ with Checking Null Elements(帶有檢查空元素的 XML 到 LINQ)
                Reading XML with unclosed tags in C#(在 C# 中讀取帶有未閉合標(biāo)簽的 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>
                          主站蜘蛛池模板: 色哟哟一区二区三区 | 视频在线一区 | 在线观看欧美日韩 | 亚洲激情网| 日本成人精品 | 亚洲视频免费看 | 亚洲一区二区三区中文字幕 | 精品国产精品三级精品av网址 | 精品国产伦一区二区三区 | 国产一级一片免费播放放a 免费国产视频 | 亚洲综合成人网 | 一区二区三区四区在线视频 | 中文字幕亚洲视频 | 黄色精品视频 | 亚洲天堂男人天堂 | 亚洲一区视频 | 黄色小说在线免费观看 | 中文字幕第三页 | 永久免费看mv网站入口亚洲 | av在线播放网站 | 国产精品国产三级国产aⅴ浪潮 | 日韩av不卡在线观看 | 亚洲精品久久久久久久久 | 91最新网址 | 国产伦理一区 | 日本一级大毛片a一 | 欧美亚洲天堂 | av免费网站 | 手机看片日韩 | 成人a毛片| 午夜激情影院 | 精品亚洲一区二区三区 | 色影视 | 日本亚洲天堂 | 五月天在线 | 免费久久久 | 亚洲综合五月天婷婷丁香 | 日本黄a三级三级三级 | 亚洲一区二区久久 | 亚洲精品在线视频 | 欧美视频一区二区 |