안녕하세요 저는 텍스트 파일에서 json 데이터를 읽으려고하고 있지만 작동하지 않습니다. 웹 사이트에서 데이터를 가져 오려고하면 정상적으로 작동합니다. 누구든지이 문제를 해결할 수있는 해결책을 알고 있습니까? 사전에 감사합니다. 파일에서 Json 데이터 읽기
private void Form1_Load(object sender, EventArgs e)
{
string path = @"C:\Users\spacefrog\Documents\Visual Studio 2017\Projects\json_test_solution\json_test\bin\Debug\test.json";
// Stream stream = File.OpenRead(path);
WebClient client = new WebClient();
Stream stream = client.OpenRead("https://www.cryptocompare.com/api/data/coinlist/"); // works perfect
/*
Stream stream = client.OpenRead(path); // doesn't work
Stream stream = File.OpenRead(path); // doesn't work
*/
/* File Data content (same as website)
{
"Response": "Success",
"Message": "Coin list succesfully returned!",
"BaseImageUrl": "https://www.cryptocompare.com",
"BaseLinkUrl": "https://www.cryptocompare.com",
"Data": {
"LTC": {
"Id": "3808",
"Url": "/coins/ltc/overview",
"ImageUrl": "/media/19782/ltc.png",
"Name": "LTC",
"CoinName": "Litecoin",
"FullName": "Litecoin (LTC)",
"Algorithm": "Scrypt",
"ProofType": "PoW",
"SortOrder": "2"
}
...
},
"Type": 100
}
*/
StreamReader reader = new StreamReader(stream);
JObject json = JObject.Parse(reader.ReadLine());
stream.Close();
MessageBox.Show((string)json["Response"]);
}
무슨 에러가 발생합니까에게 가고 싶어? '그다지 효과가 없다 '는 것은 그다지 설명 적이 지 않다. –