-
-
Save terrajobst/336da6ae0a327bef113c1325710164f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var options = new JsonWriterOptions | |
{ | |
Indented = true | |
}; | |
using (var stream = new MemoryStream()) | |
{ | |
using (var writer = new Utf8JsonWriter(stream, options)) | |
{ | |
writer.WriteStartObject(); | |
writer.WriteString("date", DateTimeOffset.UtcNow); | |
writer.WriteNumber("temp", 42); | |
writer.WriteEndObject(); | |
} | |
string json = Encoding.UTF8.GetString(stream.ToArray()); | |
Console.WriteLine(json); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment