Search code examples
c#jupyter-notebook.net-6.0dotnet-interactive.net-interactive

NET interactive notebook, cannot use System.Text.Json


I am evaluating NET interactive notebooks. I downloaded the VS code extension and created a dib notebook file.

Following this example on how to include packages, I am getting a 401 unauthenticated response when trying to use System.Text.Json... Tbh, I'm at a loss about what's happening. Can you make sense of it?

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

enter image description here

Cheers


Solution

  • You don't need to install nuget for System.Text.Json just add using System.Text.Json; to the top of your file instead of nuget import:

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