Solved

parsing json call

Posted on 2013-12-11
2
270 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
Comment Utility
Try using JSON.Net

Hope that helps.
0
 
LVL 10

Accepted Solution

by:
joriszwaenepoel earned 250 total points
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now