C# 我想用C语言获取json解析数据

C# 我想用C语言获取json解析数据,c#,json,C#,Json,这是我的JObject.Parse字符串 {"topic":{"account_id":190884,"created_at":"2015-01-31T16:35:59+05:00","delta":true,"forum_id":5000225377,"hits":0,"id":5000025527,"import_id":null,"last_post_id":5000040596,"locked":false,"merged_topic_id":null,"posts_count":0,"

这是我的JObject.Parse字符串

{"topic":{"account_id":190884,"created_at":"2015-01-31T16:35:59+05:00","delta":true,"forum_id":5000225377,"hits":0,"id":5000025527,"import_id":null,"last_post_id":5000040596,"locked":false,"merged_topic_id":null,"posts_count":0,"published":true,"replied_at":"2015-01-31T16:35:59+05:00","replied_by":5005399997,"stamp_type":null,"sticky":0,"title":"I want use API of Freshdesk.","updated_at":"2015-01-31T16:35:59+05:00","user_id":5005399997,"user_votes":0,"posts":[{"account_id":190884,"answer":false,"body":" I want to use API of Freshdesk to get forums of Freshdesk. I want to access users and posts from different Forums and show that data in my Application. I want to develop C# console Application.\u00a0  Anyone please help me. \r\n","body_html":"\u003Cp\u003EI want to use API of Freshdesk to get forums of Freshdesk. I want to access users and posts from different Forums and show that data in my Application. I want to develop C# console Application.\u00a0\u003C/p\u003E\u003Cp\u003EAnyone please help me.\u003C/p\u003E\r\n","created_at":"2015-01-31T16:35:59+05:00","forum_id":5000225377,"id":5000040596,"import_id":null,"published":true,"spam":null,"topic_id":5000025527,"trash":false,"updated_at":"2015-01-31T16:35:59+05:00","user_id":5005399997}]}}

我想用C从这个字符串中获取帖子的值。任何人都可以帮助我如何从这个字符串中获取帖子的值。

使用Newtonsoft的Json.net

这是一个易于使用的库:

例如:

string json = @"{
  'Name': 'Bad Boys',
  'ReleaseDate': '1995-4-7T00:00:00',
  'Genres': [
  'Action',
  'Comedy'
]
}";

Movie m = JsonConvert.DeserializeObject<Movie>(json);

string name = m.Name;

有很多类似的问题。请参阅,例如,我在应用程序中包括了newtonsoft。但这对我没有帮助。我也试过这个。在测试中有我的字符串。这是我的其他课程。公共类主题{public int account_id{get;set;}公共ICollection posts{get;set;}公共类Post{public int account_id{get;set;}公共bool answer{get;set;}公共字符串体{get;set;}公共字符串体{html{get;set;}主题ABC=JsonConvert.DeserializeObjecttest;当我调试它并检查ABC的值时。显示空值。在给定的字符串中,有一个额外的级别包含主题对象。添加这个类:公共类Root{public Topic Topic{get;set;}}},然后只调用Root ABC=JsonConvert.DeserializeObjecttest;这在.netcore中不起作用
var s=<json_string>;
var firstPost = JObject.Parse(s)["topic"]["posts"][0];
string postBody = (string)firstPost["body"];