Solved

parsing json call

Posted on 2013-12-11
2
281 Views
Last Modified: 2013-12-11
Hi, i'm calling a function (ipinfo.io) to get info about geo.
The result back is like this;

{
  "ip": "8.8.8.8",
  "hostname": "google-public-dns-a.google.com",
  "loc": "37.385999999999996,-122.0838",
  "org": "AS15169 Google Inc.",
  "city": "Mountain View",
  "region": "California",
  "country": "US",
  "phone": 650
}

How can I parse this now directly into variables or maybe class with properties ip, hostname, loc etc?

What is the easiest way for this in a forms application, not asp?
0
Comment
Question by:duup
2 Comments
 
LVL 25

Assisted Solution

by:Luis Pérez
Luis Pérez earned 250 total points
ID: 39711021
Try using JSON.Net

Hope that helps.
0
 
LVL 10

Accepted Solution

by:
joriszwaenepoel earned 250 total points
ID: 39711028
I have used Newtonsoft.Json.Linq in the past:

The code looks like this (but I'm not sure if this is the best way tio use that library):

            Dim obj As JObject = JObject.Parse(json)

            Dim packetType As String = obj.Item("packetType").ToString()
            Dim machineID = obj.Item("machine_id").ToString()
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

680 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