Patrik Svensson 54be64ec84
Add JSON text renderer (#1086)
* Add JsonText widget to render highlighted JSON

Closes #1051
2022-12-31 18:17:15 +00:00

37 lines
862 B
C#

using Spectre.Console;
using Spectre.Console.Json;
namespace Json;
public static class Program
{
public static void Main()
{
var json = new JsonText(
"""
{
"hello": 32,
"world": {
"foo": 21,
"bar": 255,
"baz": [
0.32, 0.33e-32,
0.42e32, 0.55e+32,
{
"hello": "world",
"lol": null
}
]
}
}
""");
AnsiConsole.Write(
new Panel(json)
.Header("Some JSON in a panel")
.Collapse()
.RoundedBorder()
.BorderColor(Color.Yellow));
}
}