Skip to content

.Net Core 3.0 cannot load custom addin #3090

Answered by devlead
markofranjic asked this question in Q&A
Discussion options

You must be logged in to vote

System.Text.Json assembly isn't currently automatically loaded under .NET Core 3, but you can load it, example:

 #r "System.Text.Json"

public class WeatherForecast
{
    public DateTimeOffset Date { get; set; }
    public int TemperatureC { get; set; }
    public string Summary { get; set; }
}

static string SerializeAsJson<T>(this T value)
{
    return System.Text.Json.JsonSerializer.Serialize<T>(value);
}

var weatherForecast = new WeatherForecast{
    Date = DateTimeOffset.UtcNow,
    TemperatureC = 11,
    Summary ="Cloudy"
};

var json = weatherForecast.SerializeAsJson();

Information(json);

will output

{"Date":"2019-11-04T13:03:47.0779982+00:00","TemperatureC":11,"Summary":"Cloudy"}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by augustoproiete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2655 on February 06, 2021 04:28.