【问题标题】:NET interactive notebook, cannot use System.Text.JsonNET 交互式笔记本,不能使用 System.Text.Json
【发布时间】:2021-11-17 15:41:04
【问题描述】:

我正在评估 NET 交互式笔记本。我下载了 VS 代码扩展并创建了一个 dib 笔记本文件。

this 示例关于如何包含软件包之后,我在尝试使用System.Text.Json 时收到了未经身份验证的 401 响应... Tbh,我对正在发生的事情感到茫然。你能理解吗?

#r "nuget:System.Text.Json"
var t = "ttt";
var x = new { t };
System.Console.WriteLine(JsonSerializer.Serialize(x));

干杯

【问题讨论】:

标签: jupyter-notebook .net-6.0 dotnet-interactive


【解决方案1】:

您不需要为 System.Text.Json 安装 nuget,只需将 using System.Text.Json; 添加到文件顶部而不是 nuget 导入:

using System;
using System.Text.Json;
var t = "ttt";
var x = new { t };
Console.WriteLine(JsonSerializer.Serialize(x));

【讨论】:

    猜你喜欢
    • 2021-08-27
    • 1970-01-01
    • 2020-08-24
    • 1970-01-01
    • 2016-07-04
    • 1970-01-01
    • 2020-07-19
    • 2017-03-22
    • 1970-01-01
    相关资源
    最近更新 更多