Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

JSON From Web

Posted on June 18, 2015October 26, 2015 By David Kittell
  1. Use NuGet, search and install “Json.net” from Newtonsoft
  2. Visit json2csharp.com with the sample Json formatted text. json2csharp will create the public class for your json file/text
    1. Paste your Json text into the text box and click on the “Generate” button
    2. Copy the generated class into your code
  3. Create a dataGridView (Windows form) or GridView (Web Form)
#region Using Statements - Start
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using Newtonsoft.Json;
using System.Net;
#endregion Using Statements - Stop


namespace JSONFromWeb
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		private void Form1_Load(object sender, EventArgs e)
		{
			DownloadJson("<Your Json URL>");
		}

		public void DownloadJson(string address)
		{
			WebClient wc = new WebClient();
			Uri uri = new Uri(address);
			wc.DownloadStringCompleted += (sender, e) =>
			{
				var deserialized =
					    JsonConvert.DeserializeObject<List<jsondata.MemberList>>(e.Result);
				dataGridView1.DataSource = deserialized;

			};

			wc.DownloadStringAsync(new Uri(address));
		}
	}
}

namespace jsondata
{
	public class MemberList
	{
		public string last_name { get; set; }
		public string first_name { get; set; }
		public string gender { get; set; }
		public string Address { get; set; }
		public string phone { get; set; }
		public double zip_lat { get; set; }
		public double zip_lon { get; set; }
		public double distance { get; set; }
	}
}
Originally Posted on June 18, 2015
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code CSharp JSON

Post navigation

Previous post
Next post

Related Posts

Regex Replace

Posted on August 6, 2013October 26, 2015

IF OBJECT_ID(N’dbo.RegexReplace’) IS NOT NULL DROP FUNCTION dbo.RegexReplace GO CREATE FUNCTION dbo.RegexReplace ( @pattern VARCHAR(255) ,@replacement VARCHAR(255) ,@Subject VARCHAR(MAX) ,@global BIT = 1 ,@Multiline BIT = 1 ) RETURNS VARCHAR(MAX) /*The RegexReplace function takes three string parameters. The pattern (the regular expression) the replacement expression, and the subject string to…

Read More

File Exists

Posted on December 14, 2013October 26, 2015

Public Function FileExists(ByVal FileFullPath As String) _ As Boolean Dim f As New IO.FileInfo(FileFullPath) Return f.Exists End Function Originally Posted on December 14, 2013Last Updated on October 26, 2015 All information on this site is shared with the intention to help. Before any source code or program is ran on…

Read More

PowerShell Azure – Get First Available IP From IP Range

Posted on October 27, 2016

If you build virtual machines in Azure you may find this script useful. Currently it’s not the fastest it could likely be if you have a large subnet but it works for my needs. It mixes two resources to make what I needed. Resources: 1. List IP addresses in a…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes