Parsing Json data from facebook in c#

When we use Facebook social authentication process ( I mean Login by Facebook) after successful authentication from Facebook we get user information in Json format. Now we have situation to how to deserialize json format data. For this purpose we have several option for deserialize json data. Either we can use some third party tool to parse json data or we can use JavaScriptSerializer.

Option Can we have when we think in terms of third party tool:
1)parsing JSon using
2)JSON Checker

So How we can achieve Json parsing without ant third party tool:

Json Data which We have to parse:

var responseText = @"{
"name":"Nishant Sharma",

So For above json format data you can create Class I have created

public class UserInformation
public string id { get; set; }
public string name { get; set; }
public string first_name { get; set; }
public string last_name { get; set; }
public string link { get; set; }
public string gender { get; set; }
public string email { get; set; }
public double timezone { get; set; }
public string locale { get; set; }
public bool verified { get; set; }
public string updated_time { get; set; }


Now use JavaScriptSerializer

JavaScriptSerializer objJavaScriptSerializer = new JavaScriptSerializer();
UserInformationparsedData = objJavaScriptSerializer.Deserialize(responseText);

It will successfully parse data to UserInformation object.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s