?
Solved

How to interpret JSON data using ASP.net?

Posted on 2011-05-05
6
Medium Priority
?
341 Views
Last Modified: 2012-05-11
://www.facebook.com/platform",
   "category": "Product/service",
   "likes": 1880909,
   "website": "http://developers.facebook.com",
   "username": "platform",
   "founded": "May 2007",
   "company_overview": "Facebook Platform enables anyone to build social applications on Facebook and the web.",
   "mission": "To make the web more open and social."
}

Now my question is, how to i parse and use these data to be used in my server script (i'm using VB.net)?

Any help is greatly appreciated.

Thanks.

Dim strFacebookURL As String = "https://graph.facebook.com/{0}"

        Dim strUserid As String = "19292868552"

        'Reconstruct the URL
        Dim strFormattedUri As String = String.Format(strFacebookURL, strUserid)

        Dim webRequest As HttpWebRequest = GetWebRequest(strFormattedUri)

        Dim response As HttpWebResponse = webRequest.GetResponse()

        Dim strJSONResponse As String = String.Empty

        Using sr As New StreamReader(response.GetResponseStream)
            strJSONResponse = sr.ReadToEnd
        End Using

Open in new window

0
Comment
Question by:tangteng78
6 Comments
 
LVL 9

Expert Comment

by:radcaesar
ID: 35698259
0
 
LVL 31

Expert Comment

by:MlandaT
ID: 35701480
0
 

Author Comment

by:tangteng78
ID: 35712808
Hi MlandaT,
I'm stuck on the c sharp code here (since i'm on VB.net).

string jsonText = @"[""Europe"", ""Asia"", ""Australia"", ""Antarctica"",
 ""North America"", ""South America"", ""Africa""]";

What's the equivalent of the code above in vb.net? Any help would be greatly appreciated.

Thanks
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

Author Comment

by:tangteng78
ID: 35712831
And the equivalent of this line of code as well in Vb.net

string[] continents = (string[]) JsonConvert.Import(typeof(string[]),
 jsonText);


??

Again, any help is greatly appreciated.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1400 total points
ID: 35716171
Try


Dim jsonText As String = "[""Europe"", ""Asia"", ""Australia"", ""Antarctica""," & vbCr & vbLf & " ""North America"", ""South America"", ""Africa""]"

Dim continents As String() = DirectCast(JsonConvert.Import(GetType(String()), jsonText), String())
0
 
LVL 31

Assisted Solution

by:MlandaT
MlandaT earned 600 total points
ID: 35718596
FYI: Here is a free tool to convert between C# and VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question