Solved

parsing json call

Posted on 2013-12-11
2
278 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
.NET tools for adding thread safety to a web app? 3 31
Alert on Server memory 2 19
VB.NET 1 21
Sql server, import complete table, using vb.net 9 33
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

808 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