Solved

parsing json call

Posted on 2013-12-11
2
287 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…

752 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