using Newtonsoft.Json; using System.IO; namespace Common.JsonFileParsing { public class JsonFileParsing { //로컬 사용 //private readonly static string rootpath = AppDomain.CurrentDomain.BaseDirectory + "..//Common/JsonFileParsing/JsonTable/"; //UAT 사용 //private readonly static string rootpath = "D:\\HOSTING\\UAT\\UAT-JSONRX-API\\App_Data\\JsonFile\\"; //Storage 사용 ( 아직 주소 제대로미지정 ) // //private readonly static string rootpath = "D:\\HOSTING\\STAGE\\STAGE-JSONRX-API\\App_Data\\JsonFile\\"; private readonly static string rootpath = "D:\\API-Live\\GME-MOBILE-API\\App_Data\\JsonFile\\"; /// /// json 파싱 함수 T 타입이 Generic Type 경우 Json 파일 명을 path 에 넣어준다. path string 입력 T 타입이 Class 경우 /// 클래스 명과 파일 이름을 일치 시켜준다. path string 입력안해도됌 /// /// /// /// public static T Deserialize(string path = "") { var typeName = typeof(T); if (typeName.IsGenericType == false) { path = typeName.Name; } using (StreamReader r = new StreamReader(rootpath + path + ".json")) { var json = r.ReadToEnd(); var parsingResult = JsonConvert.DeserializeObject(json); return parsingResult; } } } }