Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CSS
This is my JObject.Parse string.

{
"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.  Anyone please help me. \r\n",
"body_html": "<p>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. </p><p>Anyone please help me.</p>\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
}
]
}
}

I want to get values of (posts) from this string in C#. Anyone can help me how i can get values of posts from this string.
Posted
Comments
BillWoodruff 2-Feb-15 3:42am    
Have you started writing code ? What have you tried ?
Thanks7872 2-Feb-15 3:42am    
https://www.google.co.in/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=parse%20json%20object%20c%23

1 solution

How about json.net? http://www.newtonsoft.com/json[^]

Good luck!
 
Share this answer
 
Comments
Member 9893793 2-Feb-15 4:34am    
I include newtonsoft in my application. but it's not helpful for me.
I also try this. In test there is my string.
here is my other classes.
public class Topic
{
public int account_id { get; set; }
public ICollection<Post> posts { get; set; }
}
public class Post
{
public int account_id { get; set; }
public bool answer { get; set; }
public string body { get; set; }
public string body_html { get; set; }
}
Topic ABC = JsonConvert.DeserializeObject<topic>(test);
when i debug it and check the value of ABC. there is null value shows.
E.F. Nijboer 2-Feb-15 12:12pm    
How about including the type?
Topic ABC = JsonConvert.DeserializeObject<Topic>(test);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900