Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将整个appsettings.json文件作为字符串读取_Json_Vb.net_Appsettings - Fatal编程技术网

将整个appsettings.json文件作为字符串读取

将整个appsettings.json文件作为字符串读取,json,vb.net,appsettings,Json,Vb.net,Appsettings,我希望将我的appsettings.json文件的全部内容读入NewtonSoft.json,以便使用NewtonSoft解析它 这是因为能够在NewtonSoft(过滤等)中使用完整的JSON路径 我基本上只想将整个appsettings.json文件作为字符串读取 我已经让它根据配置工作了 Private Shared Function InitConfig() As IConfigurationRoot Try Dim builder

我希望将我的
appsettings.json
文件的全部内容读入NewtonSoft.json,以便使用NewtonSoft解析它

这是因为能够在NewtonSoft(过滤等)中使用完整的JSON路径

我基本上只想将整个
appsettings.json
文件作为字符串读取

我已经让它根据配置工作了

Private Shared Function InitConfig() As IConfigurationRoot
            Try
                Dim builder = New ConfigurationBuilder() _
                .AddJsonFile("appsettings.json", True, True) _
                .AddEnvironmentVariables()
                Return builder.Build
            Catch ex As Exception
                Console.WriteLine(ex.Message)
                Return Nothing
            End Try
        End Function
但是,我不想选择具体内容,例如
config(“test1:test:bot\u令牌”)
。我希望只读取整个字符串,但是我似乎无法从ConfigurationRoot获取该字符串


Cheers

完全错误地处理了这个问题-只是使用了streamreader来读取appsettings.json文件

完整的大脑放屁时刻

Dim tr As TextReader = New StreamReader("appsettings.json")
Dim stream = tr.ReadToEnd

听起来不错,你试过哪些,哪些不起作用?请更新您的帖子以包含代码,以便我们可以进一步帮助您。@Codexer-Updated。