2017-12-20 6 views
1

vb.net을 사용하여 json 파일을 읽으려는 것으로 시작하고 있습니다. 매우 기본적인 코드와 함께 .json 파일로 저장 한 매우 간단한 텍스트 샘플이 있습니다.json 파일을 vb.net에 업로드 할 수 없습니다.

Imports System.IO 
Module Module1 

    Sub Main() 
     Dim json As String = File.ReadAllText("C:\Users\cmannar\sample2.json") 
     Console.WriteLine() 
     Console.Read() 

    End Sub 
End Module 

내 간단한 텍스트 파일이 sample2.json이라고하며 여기에 있습니다 : : 다음은 코드입니다

[{ 
    "id": 1, 
    "first_name": "Jeanette", 
    "last_name": "Penddreth", 
    "email": "[email protected]", 
    "gender": "Female", 
    "ip_address": "26.58.193.2" 
}, { 
    "id": 2, 
    "first_name": "Giavani", 
    "last_name": "Frediani", 
    "email": "[email protected]", 
    "gender": "Male", 
    "ip_address": "229.179.4.212" 
}, { 
    "id": 3, 
    "first_name": "Noell", 
    "last_name": "Bea", 
    "email": "[email protected]", 
    "gender": "Female", 
    "ip_address": "180.66.162.255" 
}, { 
    "id": 4, 
    "first_name": "Willard", 
    "last_name": "Valek", 
    "email": "[email protected]", 
    "gender": "Male", 
    "ip_address": "67.76.188.26" 
}] 

그것은 잘 컴파일 오류가없는,하지만 내에서 인쇄되지 않습니다. json 파일. 그것은 빈 화면으로 유지됩니다. 누군가 내가 잘못 들어간 곳을 나에게 보여줄 수 있다면 크게 환영 할 것입니다! 사전에 감사

답변

1

당신은, 당신은 단지 빈 줄 인쇄 파일을 인쇄하지 않습니다 : 파일의 내용을 인쇄 할 경우 어떤 당신을 Console.WriteLine 말할 필요,

Console.WriteLine() 

을 인쇄하고 싶습니다 :

Console.WriteLine(json) 
+0

아, 나는 그것을 놓쳤다는 것을 믿을 수 없습니다. 고맙습니다! –

관련 문제