👨🏼💻개발/C#
C# - 간단한 API 요청 & JSON 출력
Janger
2022. 2. 2. 08:26
728x90
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 System.Net;
using Newtonsoft.Json.Linq;
namespace covidView
{
public partial class Form1 : Form
{
private const string URL = "https://api.corona-19.kr/korea/beta/";
private string api = "?serviceKey={Your_APIKEY}";
public Form1()
{
InitializeComponent();
Console.WriteLine("Hello world!");
using (WebClient wc = new WebClient())
{
string res = new WebClient().DownloadString(URL + api);
JObject json = JObject.Parse(res);
Console.WriteLine(json["API"]);
}
}
}
}
참고:
C# 주소에 요청 보내고 json 값 받기
using System.Net; namespace WindowsFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); button1.Click += request; } private void request(object sender, EventArgs e..
fors.tistory.com
https://stackoverflow.com/questions/22870624/convert-json-string-to-json-object-c-sharp
Convert JSON String to JSON Object c#
I have this String stored in my database: str = "{ "context_name": { "lower_bound": "value", "upper_bound": "value", "values": [ "value1", "valueN" ] } }" This string is already in the JSON forma...
stackoverflow.com
728x90