본문 바로가기
프로그래밍/C#

간단한 json reader 만들기

by 체리 2021. 3. 14.
반응형

웹에 있는 json file을 가져와 읽어보는 간단한 code

 

json 위치: github.com/microsoft/vscode-cpptools/blob/main/Extension/package.json

 

microsoft/vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code. - microsoft/vscode-cpptools

github.com

순수 json 위치: raw.githubusercontent.com/microsoft/vscode-cpptools/main/Extension/package.json

 

code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string url = "https://raw.githubusercontent.com/microsoft/vscode-cpptools/main/Extension/package.json";
            string json = new WebClient().DownloadString(url);
            JObject jObj = JObject.Parse(json);

            Console.WriteLine(jObj["name"]);
            Console.WriteLine(jObj["displayName"]);
            Console.WriteLine(jObj["version"]);
            Console.WriteLine(jObj["engines"]["vscode"]);
        }
    }
}

 

참고

vscode extension dir은 publisher.name.version 인듯

반응형

'프로그래밍 > C#' 카테고리의 다른 글

간단한 XML reader  (0) 2021.03.14

댓글