久久久久久久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 對象創建一個以 ID 為名稱的強類型 c# 對象

      Create a strongly typed c# object from json object with ID as the name(從 json 對象創建一個以 ID 為名稱的強類型 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 對象創建一個以 ID 為名稱的強類型 c# 對象的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

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

                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# 中創建一個強類型對象,以便處理這些數據.我可以為 pollsAndSurveys 位和出勤位創建對象,但我不知道如何處理 id 號,在本例中為 5234592 &5235291,即會話的標識符.

                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 對象,并將鍵轉換為屬性名稱.在您的情況下,ID 號將被反序列化為字典鍵.如果您確定它們將始終是數字,則可以這樣聲明它們:

                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);
                

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

                這篇關于從 json 對象創建一個以 ID 為名稱的強類型 c# 對象的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
                  <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. 主站蜘蛛池模板: 三级黄色片在线观看 | www4虎 | 婷婷久久五月天 | 亚洲网站在线观看 | a免费在线 | 国产精品一区二区视频 | 久久男人天堂 | 日本一二区视频 | 久在线| 91久久精品国产91久久性色tv | 91热在线| 在线一区二区国产 | 日本在线综合 | 欧美福利影院 | 亚洲一区二区三区桃乃木香奈 | 99久久成人 | 91精品国产色综合久久 | 国产精品久久久久无码av | 欧美一级黄色片免费观看 | 亚洲成人日韩 | 精久久| 欧美在线二区 | 国产精品亚洲精品久久 | 一区二区三区四区在线 | 欧美一区精品 | 好姑娘高清在线观看电影 | 91精品国产综合久久久久久 | 成人精品一区亚洲午夜久久久 | 99精品免费视频 | h视频免费看 | 国产一区在线免费 | 91久久精品日日躁夜夜躁国产 | 欧美一级片在线观看 | 久久av资源网 | 久久高清国产视频 | 日韩视频在线免费观看 | 午夜电影福利 | 久久久久久91香蕉国产 | 99热精品在线 | 亚洲精品v日韩精品 | 亚洲精品一区二区三区免 |