Json到C#模型问题类总是返回null
以下是我的json示例:Json到C#模型问题类总是返回null,c#,json,asp.net-mvc,json-deserialization,jsonmodel,C#,Json,Asp.net Mvc,Json Deserialization,Jsonmodel,以下是我的json示例: { "generated_at": "2020-11-24T11:27:57+00:00", "summaries": [ { "sport_event": { "id": "sr:sport_event:22762631", &qu
{
"generated_at": "2020-11-24T11:27:57+00:00",
"summaries": [
{
"sport_event": {
"id": "sr:sport_event:22762631",
"start_time": "2020-11-24T10:00:00+00:00",
"start_time_confirmed": true,
"sport_event_context": {
"sport": {
"id": "sr:sport:1",
"name": "Futbol"
},
"category": {
"id": "sr:category:393",
"name": "Uluslararas\u0131 Kul\u00fcpler"
},
"competition": {
"id": "sr:competition:463",
"name": "AFC \u015eampiyonlar Ligi"
},
"season": {
"id": "sr:season:74427",
"name": "AFC \u015eampiyonlar Ligi 2020",
"start_date": "2020-01-14",
"end_date": "2020-12-19",
"year": "2020",
"competition_id": "sr:competition:463"
},
"stage": {
"order": 3,
"type": "league",
"phase": "regular season",
"start_date": "2020-02-11",
"end_date": "2020-12-03",
"year": "2020"
},
"round": {
"number": 4
},
"groups": [
{
"id": "sr:league:49469",
"name": "AFC Champions League 2020, Group E",
"group_name": "E"
}
]
},
"coverage": {
"type": "sport_event",
"sport_event_properties": {
"lineups": true,
"extended_player_stats": false,
"extended_team_stats": false,
"lineups_availability": "pre",
"ballspotting": true,
"commentary": true,
"fun_facts": true,
"goal_scorers": true,
"scores": "live",
"game_clock": true,
"deeper_play_by_play": true,
"deeper_player_stats": true,
"deeper_team_stats": true,
"basic_play_by_play": true,
"basic_player_stats": true,
"basic_team_stats": true
}
},
"competitors": [
{
"id": "sr:competitor:3376",
"name": "Beijing Guoan",
"country": "\u00c7in",
"country_code": "CHN",
"abbreviation": "BJG",
"qualifier": "home",
"gender": "male"
},
{
"id": "sr:competitor:5970",
"name": "Melbourne Victory FC",
"country": "Avustralya",
"country_code": "AUS",
"abbreviation": "MEV",
"qualifier": "away",
"gender": "male"
}
],
"venue": {
"id": "sr:venue:54139",
"name": "Education City Stadium",
"capacity": 45350,
"city_name": "Al Rayyan",
"country_name": "Katar",
"map_coordinates": "25.310846, 51.424414",
"country_code": "QAT"
},
"sport_event_conditions": {
"referees": [
{
"id": "sr:referee:2101998",
"name": "Al-Abda, Saoud",
"type": "main_referee"
}
],
"ground": {
"neutral": true
}
}
},
"sport_event_status": {
"status": "live",
"match_status": "2nd_half",
"home_score": 2,
"away_score": 0,
"period_scores": [
{
"home_score": 2,
"away_score": 0,
"type": "regular_period",
"number": 1
},
{
"home_score": 0,
"away_score": 0,
"type": "regular_period",
"number": 2
}
],
"ball_locations": [
{
"order": 4,
"x": 24,
"y": 25,
"qualifier": "home"
},
{
"order": 3,
"x": 28,
"y": 54,
"qualifier": "home"
},
{
"order": 2,
"x": 31,
"y": 72,
"qualifier": "home"
},
{
"order": 1,
"x": 34,
"y": 75,
"qualifier": "home"
}
],
"clock": {
"played": "70:17"
}
},
"statistics": {
"totals": {
"competitors": [
{
"id": "sr:competitor:3376",
"name": "Beijing Guoan",
"abbreviation": "BJG",
"qualifier": "home",
"statistics": {
"yellow_cards": 1,
"yellow_red_cards": 0,
"red_cards": 0,
"corner_kicks": 3,
"shots_total": 7,
"shots_on_target": 4,
"shots_off_target": 2,
"shots_blocked": 1,
"ball_possession": 65,
"free_kicks": 13,
"offsides": 1,
"goal_kicks": 4,
"throw_ins": 13,
"shots_saved": 0,
"fouls": 9,
"injuries": 1,
"cards_given": 1,
"substitutions": 3
},
"players": [
{
"statistics": {
"goals_scored": 0,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 0,
"substituted_in": 0,
"substituted_out": 0,
"offsides": 0,
"corner_kicks": 0,
"shots_on_target": 0,
"shots_off_target": 0,
"shots_blocked": 0
},
"id": "sr:player:328303",
"name": "Sen, Hou",
"starter": true
},
{
"statistics": {
"goals_scored": 0,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 0,
"substituted_in": 0,
"substituted_out": 0,
"offsides": 0,
"corner_kicks": 0,
"shots_on_target": 0,
"shots_off_target": 0,
"shots_blocked": 0
},
"id": "sr:player:1272814",
"name": "Kim, Min-Jae",
"starter": true
},
{
"statistics": {
"goals_scored": 0,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 0,
"substituted_in": 0,
"substituted_out": 0,
"offsides": 0,
"corner_kicks": 0,
"shots_on_target": 0,
"shots_off_target": 0,
"shots_blocked": 0
},
"id": "sr:player:261597",
"name": "Yang, Yu",
"starter": true
},
{
"statistics": {
"goals_scored": 1,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 1,
"substituted_in": 0,
"substituted_out": 0,
"offsides": 1,
"corner_kicks": 0,
"shots_on_target": 1,
"shots_off_target": 1,
"shots_blocked": 0
},
"id": "sr:player:34152",
"name": "Renato Augusto",
"starter": true
},
{
"statistics": {
"goals_scored": 0,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 0,
"substituted_in": 0,
"substituted_out": 1,
"offsides": 0,
"corner_kicks": 1,
"shots_on_target": 0,
"shots_off_target": 0,
"shots_blocked": 0
},
"id": "sr:player:231992",
"name": "Xizhe, Zhang",
"starter": true
},
{
"statistics": {
"goals_scored": 0,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 0,
"substituted_in": 0,
"substituted_out": 0,
"offsides": 0,
"corner_kicks": 0,
"shots_on_target": 0,
"shots_off_target": 0,
"shots_blocked": 0
},
"id": "sr:player:59872",
"name": "Dabao, Yu",
"starter": false
},
{
"statistics": {
"goals_scored": 0,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 0,
"substituted_in": 0,
"substituted_out": 0,
"offsides": 0,
"corner_kicks": 0,
"shots_on_target": 0,
"shots_off_target": 0,
"shots_blocked": 0
},
"id": "sr:player:1418851",
"name": "Fan, Yang",
"starter": false
},
{
"statistics": {
"goals_scored": 0,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 0,
"substituted_in": 0,
"substituted_out": 0,
"offsides": 0,
"corner_kicks": 0,
"shots_on_target": 0,
"shots_off_target": 0,
"shots_blocked": 0
},
"id": "sr:player:223230",
"name": "Peng, Lu",
"starter": false
},
{
"statistics": {
"goals_scored": 0,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 0,
"substituted_in": 0,
"substituted_out": 0,
"offsides": 0,
"corner_kicks": 0,
"shots_on_target": 0,
"shots_off_target": 0,
"shots_blocked": 0
},
"id": "sr:player:328311",
"name": "Tao, Jiang",
"starter": false
},
{
"statistics": {
"goals_scored": 0,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 0,
"substituted_in": 1,
"substituted_out": 0,
"offsides": 0,
"corner_kicks": 0,
"shots_on_target": 0,
"shots_off_target": 0,
"shots_blocked": 0
},
"id": "sr:player:815216",
"name": "Dun, BA",
"starter": false
}
]
},
{
"id": "sr:competitor:5970",
"name": "Melbourne Victory FC",
"abbreviation": "MEV",
"qualifier": "away",
"statistics": {
"yellow_cards": 1,
"yellow_red_cards": 0,
"red_cards": 0,
"corner_kicks": 3,
"shots_total": 6,
"shots_on_target": 0,
"shots_off_target": 4,
"shots_blocked": 2,
"ball_possession": 35,
"free_kicks": 10,
"offsides": 3,
"goal_kicks": 7,
"throw_ins": 21,
"shots_saved": 2,
"fouls": 10,
"injuries": 0,
"cards_given": 1,
"substitutions": 4
},
"players": [
{
"statistics": {
"goals_scored": 0,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 0,
"substituted_in": 0,
"substituted_out": 0,
"offsides": 0,
"corner_kicks": 0,
"shots_on_target": 0,
"shots_off_target": 2,
"shots_blocked": 0
},
"id": "sr:player:155973",
"name": "Ansell, Nick",
"starter": true
},
{
"statistics": {
"goals_scored": 0,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 0,
"substituted_in": 0,
"substituted_out": 1,
"offsides": 0,
"corner_kicks": 0,
"shots_on_target": 0,
"shots_off_target": 0,
"shots_blocked": 0
},
"id": "sr:player:1436448",
"name": "Kirdar, Birkan",
"starter": true
},
{
"statistics": {
"goals_scored": 0,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 0,
"substituted_in": 0,
"substituted_out": 0,
"offsides": 0,
"corner_kicks": 0,
"shots_on_target": 0,
"shots_off_target": 0,
"shots_blocked": 0
},
"id": "sr:player:122551",
"name": "Traore, Adama",
"starter": true
},
{
"statistics": {
"goals_scored": 0,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 0,
"substituted_in": 0,
"substituted_out": 0,
"offsides": 3,
"corner_kicks": 0,
"shots_on_target": 0,
"shots_off_target": 0,
"shots_blocked": 0
},
"id": "sr:player:122374",
"name": "Rojas, Marco",
"starter": true
},
{
"statistics": {
"goals_scored": 0,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 0,
"substituted_in": 0,
"substituted_out": 1,
"offsides": 0,
"corner_kicks": 0,
"shots_on_target": 0,
"shots_off_target": 0,
"shots_blocked": 0
},
"id": "sr:player:1270838",
"name": "Folami, Ben",
"starter": true
},
{
"statistics": {
"goals_scored": 0,
"yellow_cards": 0,
"yellow_red_cards": 0,
"red_cards": 0,
"own_goals": 0,
"assists": 0,
"substituted_in": 1,
"substituted_out": 0,
"offsides": 0,
"corner_kicks": 0,
"shots_on_target": 0,
"shots_off_target": 0,
"shots_blocked": 0
},
"id": "sr:player:1732609",
"name": "Anderson, Aaron",
"starter": false
}
]
}
]
}
}
}
大家好,
我试图在在线转换的网站上将json转换为c#模型,但我无法对球员或球队的统计数据做出反应。它总是返回null。如何将json-to-c#模型正确地生成到c#类?我无法得到任何球队或球员的统计数据。谢谢你帮助我
关于,//根myDeserializedClass=JsonConvert.DeserializeObject(myJsonResponse);
公共体育课{
公共字符串id{get;set;}
公共字符串名称{get;set;}
}
公共类类别{
公共字符串id{get;set;}
公共字符串名称{get;set;}
}
公开课比赛{
公共字符串id{get;set;}
公共字符串名称{get;set;}
}
公共课季{
公共字符串id{get;set;}
公共字符串名称{get;set;}
公共字符串开始日期{get;set;}
公共字符串结束日期{get;set;}
公共字符串年份{get;set;}
公共字符串竞争_id{get;set;}
}
公开课阶段{
公共整数顺序{get;set;}
公共字符串类型{get;set;}
公共字符串阶段{get;set;}
公共字符串开始日期{get;set;}
公共字符串结束日期{get;set;}
公共字符串年份{get;set;}
}
公开课轮{
公共整数{get;set;}
}
公共课组{
公共字符串id{get;set;}
公共字符串名称{get;set;}
公共字符串组_name{get;set;}
}
公共类SportEventContext{
公共体育运动{get;set;}
公共类别{get;set;}
公开竞争{get;set;}
公共季节{get;set;}
公共舞台舞台{get;set;}
公共轮{get;set;}
公共列表组{get;set;}
}
公共类SportEventProperties{
公共bool队列{get;set;}
公共布尔扩展_玩家_统计{get;set;}
公共布尔扩展团队统计{get;set;}
公共字符串列表\u可用性{get;set;}
公共bool ballspotting{get;set;}
公共布尔注释{get;set;}
公共bool fun_facts{get;set;}
公共球场进球得分者{get;set;}
公共字符串分数{get;set;}
公共布尔游戏时钟{get;set;}
公共布尔值按次播放{get;set;}
公共bool\u player\u stats{get;set;}
公共bool\u team\u stats{get;set;}
公共bool basic_play_by_play{get;set;}
公共bool basic_player_stats{get;set;}
公共bool基本团队统计{get;set;}
}
公共课覆盖率{
公共字符串类型{get;set;}
公共SportEventProperties sport_事件属性{get;set;}
}
公开赛选手{
公共字符串id{get;set;}
公共字符串名称{get;set;}
公共字符串国家{get;set;}
公共字符串国家代码{get;set;}
公共字符串缩写{get;set;}
公共字符串限定符{get;set;}
公共字符串{get;set;}
}
公共课堂场地{
公共字符串id{get;set;}
公共字符串名称{get;set;}
公共整数容量{get;set;}
公共字符串city_name{get;set;}
公共字符串country_name{get;set;}
公共字符串映射_坐标{get;set;}
公共字符串国家代码{get;set;}
}
公开课裁判员{
公共字符串id{get;set;}
公共字符串名称{get;set;}
公共字符串类型{get;set;}
}
公共类场地{
公共布尔中立{get;set;}
}
公共级别SportEventConditions{
公共列表裁判员{get;set;}
公共地面{get;set;}
}
公营体育活动{
公共字符串id{get;set;}
公共日期时间开始时间{get;set;}
公共bool开始时间确认{get;set;}
公共SportEventContext体育事件上下文{get;set;}
公共覆盖范围{get;set;}
公开列表竞争对手{get;set;}
公共场所{get;set;}
公共SportEventConditions sport_event_conditions{get;set;}
}
公开课成绩{
公共int home_分数{get;set;}
公共int-away_分数{get;set;}
公共字符串类型{get;set;}
公共整数{get;set;}
}
公共类球位{
公共整数顺序{get;set;}
公共整数x{get;set;}
公共整数y{get;set;}
公共字符串限定符{get;set;}
}
公课钟{
播放的公共字符串{get;set;}
}
公共类SportEventStatus{
公共字符串状态{get;set;}
公共字符串匹配_状态{get;set;}
公共int home_分数{get;set;}
公共int-away_分数{get;set;}
公共列表周期_分数{get;set;}
公共列表ball_位置{get;set;}
公共时钟{get;set;}
}
公共类统计2{
公共整数黄卡{get;set;}
公共int黄色\红色\卡{get;set;}
公共整数红卡{get;set;}
公共int角_kicks{get;set;}
公共int shots_total{get;set;}
目标{get;set;}上的公共int快照
public int shots_off_target{get;set;}
公共int shots_blocked{get;set;}
公共int-ball_拥有{get;set;}
公共int任意球{get;set;}
酒吧
var myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
public class Sport {
public string id { get; set; }
public string name { get; set; }
}
public class Category {
public string id { get; set; }
public string name { get; set; }
}
public class Competition {
public string id { get; set; }
public string name { get; set; }
}
public class Season {
public string id { get; set; }
public string name { get; set; }
public string start_date { get; set; }
public string end_date { get; set; }
public string year { get; set; }
public string competition_id { get; set; }
}
public class Stage {
public int order { get; set; }
public string type { get; set; }
public string phase { get; set; }
public string start_date { get; set; }
public string end_date { get; set; }
public string year { get; set; }
}
public class Round {
public int number { get; set; }
}
public class Group {
public string id { get; set; }
public string name { get; set; }
public string group_name { get; set; }
}
public class SportEventContext {
public Sport sport { get; set; }
public Category category { get; set; }
public Competition competition { get; set; }
public Season season { get; set; }
public Stage stage { get; set; }
public Round round { get; set; }
public List<Group> groups { get; set; }
}
public class SportEventProperties {
public bool lineups { get; set; }
public bool extended_player_stats { get; set; }
public bool extended_team_stats { get; set; }
public string lineups_availability { get; set; }
public bool ballspotting { get; set; }
public bool commentary { get; set; }
public bool fun_facts { get; set; }
public bool goal_scorers { get; set; }
public string scores { get; set; }
public bool game_clock { get; set; }
public bool deeper_play_by_play { get; set; }
public bool deeper_player_stats { get; set; }
public bool deeper_team_stats { get; set; }
public bool basic_play_by_play { get; set; }
public bool basic_player_stats { get; set; }
public bool basic_team_stats { get; set; }
}
public class Coverage {
public string type { get; set; }
public SportEventProperties sport_event_properties { get; set; }
}
public class Competitor {
public string id { get; set; }
public string name { get; set; }
public string country { get; set; }
public string country_code { get; set; }
public string abbreviation { get; set; }
public string qualifier { get; set; }
public string gender { get; set; }
}
public class Venue {
public string id { get; set; }
public string name { get; set; }
public int capacity { get; set; }
public string city_name { get; set; }
public string country_name { get; set; }
public string map_coordinates { get; set; }
public string country_code { get; set; }
}
public class Referee {
public string id { get; set; }
public string name { get; set; }
public string type { get; set; }
}
public class Ground {
public bool neutral { get; set; }
}
public class SportEventConditions {
public List<Referee> referees { get; set; }
public Ground ground { get; set; }
}
public class SportEvent {
public string id { get; set; }
public DateTime start_time { get; set; }
public bool start_time_confirmed { get; set; }
public SportEventContext sport_event_context { get; set; }
public Coverage coverage { get; set; }
public List<Competitor> competitors { get; set; }
public Venue venue { get; set; }
public SportEventConditions sport_event_conditions { get; set; }
}
public class PeriodScore {
public int home_score { get; set; }
public int away_score { get; set; }
public string type { get; set; }
public int number { get; set; }
}
public class BallLocation {
public int order { get; set; }
public int x { get; set; }
public int y { get; set; }
public string qualifier { get; set; }
}
public class Clock {
public string played { get; set; }
}
public class SportEventStatus {
public string status { get; set; }
public string match_status { get; set; }
public int home_score { get; set; }
public int away_score { get; set; }
public List<PeriodScore> period_scores { get; set; }
public List<BallLocation> ball_locations { get; set; }
public Clock clock { get; set; }
}
public class Statistics2 {
public int yellow_cards { get; set; }
public int yellow_red_cards { get; set; }
public int red_cards { get; set; }
public int corner_kicks { get; set; }
public int shots_total { get; set; }
public int shots_on_target { get; set; }
public int shots_off_target { get; set; }
public int shots_blocked { get; set; }
public int ball_possession { get; set; }
public int free_kicks { get; set; }
public int offsides { get; set; }
public int goal_kicks { get; set; }
public int throw_ins { get; set; }
public int shots_saved { get; set; }
public int fouls { get; set; }
public int injuries { get; set; }
public int cards_given { get; set; }
public int substitutions { get; set; }
}
public class Statistics3 {
public int goals_scored { get; set; }
public int yellow_cards { get; set; }
public int yellow_red_cards { get; set; }
public int red_cards { get; set; }
public int own_goals { get; set; }
public int assists { get; set; }
public int substituted_in { get; set; }
public int substituted_out { get; set; }
public int offsides { get; set; }
public int corner_kicks { get; set; }
public int shots_on_target { get; set; }
public int shots_off_target { get; set; }
public int shots_blocked { get; set; }
}
public class Player {
public Statistics3 statistics { get; set; }
public string id { get; set; }
public string name { get; set; }
public bool starter { get; set; }
}
public class Competitor2 {
public string id { get; set; }
public string name { get; set; }
public string abbreviation { get; set; }
public string qualifier { get; set; }
public Statistics2 statistics { get; set; }
public List<Player> players { get; set; }
}
public class Totals {
public List<Competitor2> competitors { get; set; }
}
public class Statistics {
public Totals totals { get; set; }
}
public class Summary {
public SportEvent sport_event { get; set; }
public SportEventStatus sport_event_status { get; set; }
public Statistics statistics { get; set; }
}
public class Root {
public DateTime generated_at { get; set; }
public List<Summary> summaries { get; set; }
}
[JsonProperty("statistics")] public Dictionary<string, long> Statistics { get; set; }