无法将json文件上传到vb.net

时间:2017-12-20 18:57:35

标签: json vb.net

我开始尝试使用vb.net读取json文件。我有一个非常简单的文本示例,我将其存储为.json文件以及非常基本的代码。 这是代码:

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": "jpenddreth0@census.gov",
  "gender": "Female",
  "ip_address": "26.58.193.2"
}, {
  "id": 2,
  "first_name": "Giavani",
  "last_name": "Frediani",
  "email": "gfrediani1@senate.gov",
  "gender": "Male",
  "ip_address": "229.179.4.212"
}, {
  "id": 3,
  "first_name": "Noell",
  "last_name": "Bea",
  "email": "nbea2@imageshack.us",
  "gender": "Female",
  "ip_address": "180.66.162.255"
}, {
  "id": 4,
  "first_name": "Willard",
  "last_name": "Valek",
  "email": "wvalek3@vk.com",
  "gender": "Male",
  "ip_address": "67.76.188.26"
}]

编译正常并且没有错误,但它不会打印出我的.json文件。它保持为空白屏幕。 如果有人能告诉我哪里出错了,我将不胜感激!提前谢谢

1 个答案:

答案 0 :(得分:1)

您不打印文件,只需打印一个空行:

Console.WriteLine()

如果要打印文件内容,您需要告诉Console.WriteLine 您要打印的

Console.WriteLine(json)