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

  1. <small id='zDyIz'></small><noframes id='zDyIz'>

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

    2. <legend id='zDyIz'><style id='zDyIz'><dir id='zDyIz'><q id='zDyIz'></q></dir></style></legend>

      從 json 對象創(chuàng)建一個(gè)以 ID 為名稱的強(qiáng)類型 c# 對象

      Create a strongly typed c# object from json object with ID as the name(從 json 對象創(chuàng)建一個(gè)以 ID 為名稱的強(qiáng)類型 c# 對象)

        • <legend id='ysn5i'><style id='ysn5i'><dir id='ysn5i'><q id='ysn5i'></q></dir></style></legend>

          <tfoot id='ysn5i'></tfoot>

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

              <tbody id='ysn5i'></tbody>
              <bdo id='ysn5i'></bdo><ul id='ysn5i'></ul>
              • 本文介紹了從 json 對象創(chuàng)建一個(gè)以 ID 為名稱的強(qiáng)類型 c# 對象的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我正在嘗試將 API 用于知名的在線會議提供商.他們的其中一個(gè) API 調(diào)用返回一個(gè)如下所示的對象.

                I am trying to make use of the API for a well known online meeting provider. One of their API calls returns an object that looks like this.

                {
                    "5234592":{
                    "pollsAndSurveys":{
                        "questionsAsked":1,
                        "surveyCount":0,
                        "percentageSurveysCompleted":0,
                        "percentagePollsCompleted":100,
                        "pollCount":2},
                    "attendance":{
                        "averageAttendanceTimeSeconds":253,
                        "averageInterestRating":0,
                        "averageAttentiveness":0,
                        "registrantCount":1,
                        "percentageAttendance":100}
                    },
                    "5235291":{
                    "pollsAndSurveys":{
                        "questionsAsked":2,
                        "surveyCount":0,
                        "percentageSurveysCompleted":0,
                        "percentagePollsCompleted":0,
                        "pollCount":0},
                    "attendance":{
                        "averageAttendanceTimeSeconds":83,
                        "averageInterestRating":0,
                        "averageAttentiveness":0,
                        "registrantCount":1,
                        "percentageAttendance":100}
                    }
                }
                

                我正在嘗試在 C# 中創(chuàng)建一個(gè)強(qiáng)類型對象,以便處理這些數(shù)據(jù).我可以為 pollsAndSurveys 位和出勤位創(chuàng)建對象,但我不知道如何處理 id 號,在本例中為 5234592 &5235291,即會話的標(biāo)識符.

                I am trying to make a strongly typed object in C# so I can deal with this data. I can create objects for the pollsAndSurveys bit and the attendance bit but I don't know how to deal with the id number, in this case 5234592 & 5235291, that is the identifier for the session.

                public class AttendanceStatistics
                {
                    [JsonProperty(PropertyName = "registrantCount")]
                    public int RegistrantCount { get; set; }
                
                    [JsonProperty(PropertyName = "percentageAttendance")]
                    public float PercentageAttendance{ get; set; }
                
                    [JsonProperty(PropertyName = "averageInterestRating")]
                    public float AverageInterestRating { get; set; }
                
                    [JsonProperty(PropertyName = "averageAttentiveness")]
                    public float AverageAttentiveness { get; set; }
                
                    [JsonProperty(PropertyName = "averageAttendanceTimeSeconds")]
                    public float AverageAttendanceTimeSeconds { get; set; }
                }
                
                public class PollsAndSurveysStatistics
                {
                    [JsonProperty(PropertyName = "pollCount")]
                    public int PollCount { get; set; }
                
                    [JsonProperty(PropertyName = "surveyCount")]
                    public float SurveyCount { get; set; }
                
                    [JsonProperty(PropertyName = "questionsAsked")]
                    public int QuestionsAsked { get; set; }
                
                    [JsonProperty(PropertyName = "percentagePollsCompleted")]
                    public float PercentagePollsCompleted { get; set; }
                
                    [JsonProperty(PropertyName = "percentageSurveysCompleted")]
                    public float PercentageSurveysCompleted { get; set; }
                }
                
                public class SessionPerformanceStats
                {
                    [JsonProperty(PropertyName = "attendance")]
                    public AttendanceStatistics Attendance { get; set; }
                
                    [JsonProperty(PropertyName = "pollsAndSurveys")]
                    public PollsAndSurveysStatistics PollsAndSurveys { get; set; }
                }
                
                public class WebinarPerformanceStats
                {
                    public List<SessionPerformanceStats> Stats { get; set; }
                }
                

                我很確定 WebinarPerformanceStats 是問題所在,但我不知道從哪里開始.我必須改變什么才能得到

                I am pretty sure that the WebinarPerformanceStats is the issue but I don't know where to go from here. What would I have to change to get

                NewtonSoft.Json.JsonConvert.DeserializeObject<WebinarPerformanceStats>(theJsonResponse)

                上班?

                推薦答案

                讓你的根對象成為字典:

                Make your root object be a dictionary:

                var dictionary = JsonConvert.DeserializeObject<Dictionary<string, SessionPerformanceStats>>(theJsonResponse);
                

                Json.NET 將字典從 JSON 對象序列化到 JSON 對象,并將鍵轉(zhuǎn)換為屬性名稱.在您的情況下,ID 號將被反序列化為字典鍵.如果您確定它們將始終是數(shù)字,則可以這樣聲明它們:

                Json.NET serializes a dictionary from and to a JSON object, with the keys being converted to the property names. In your case, the ID numbers will be deserialized as the dictionary keys. If you are sure they will always be numbers, you could declare them as such:

                var dictionary = JsonConvert.DeserializeObject<Dictionary<long, SessionPerformanceStats>>(theJsonResponse);
                

                參見序列化字典和反序列化字典

                這篇關(guān)于從 json 對象創(chuàng)建一個(gè)以 ID 為名稱的強(qiáng)類型 c# 對象的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 時(shí)忽略空格)
                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(解析格式錯(cuò)誤的 XML)
                  <legend id='ierKo'><style id='ierKo'><dir id='ierKo'><q id='ierKo'></q></dir></style></legend>
                  • <tfoot id='ierKo'></tfoot>
                      <bdo id='ierKo'></bdo><ul id='ierKo'></ul>
                      <i id='ierKo'><tr id='ierKo'><dt id='ierKo'><q id='ierKo'><span id='ierKo'><b id='ierKo'><form id='ierKo'><ins id='ierKo'></ins><ul id='ierKo'></ul><sub id='ierKo'></sub></form><legend id='ierKo'></legend><bdo id='ierKo'><pre id='ierKo'><center id='ierKo'></center></pre></bdo></b><th id='ierKo'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ierKo'><tfoot id='ierKo'></tfoot><dl id='ierKo'><fieldset id='ierKo'></fieldset></dl></div>

                        <tbody id='ierKo'></tbody>

                        1. <small id='ierKo'></small><noframes id='ierKo'>

                        2. 主站蜘蛛池模板: 国产精品自在线 | 中文字幕日韩高清 | 高潮一区二区三区乱码 | 九九成人 | 成人毛片在线播放 | 91九色国产 | 欧美日韩久久久 | 九九视频在线 | 欧美一区视频 | 久久少妇 | 九九热在线精品 | 天天干天天操天天摸 | 亚洲视频不卡 | 国产一区福利 | 久久久噜噜噜 | 国产aⅴ爽av久久久久成人 | 久视频在线 | 成人欧美一区二区三区黑人孕妇 | 亚洲 欧美 激情 另类 校园 | 欧洲一区二区 | 欧美日韩免费在线观看 | 日本免费毛片 | av网站在线免费观看 | 国产区视频 | 五月亚洲 | 色一情一乱一乱一区91av | 五月久久 | 三级av片 | 国产午夜一区二区三区 | 亚洲国产成人精品女人 | 国产h片在线观看 | 成人福利视频 | 国产午夜一区二区 | 伊人亚洲综合 | av免费观看网址 | 青青草免费在线观看 | 在线观看国产小视频 | 中文在线字幕免费观看 | 午夜精品福利视频 | 六月天婷婷 | 久久亚洲国产精品 |