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

问题描述 投票:1回答:1

我开始尝试使用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": "[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文件。它保持为空白屏幕。如果有人能告诉我哪里出错了,我将不胜感激!先感谢您

json vb.net
1个回答
1
投票

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

Console.WriteLine()

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

Console.WriteLine(json)
© www.soinside.com 2019 - 2024. All rights reserved.