From f761990225fd98160b52ef90f88b769c0f6b0dc6 Mon Sep 17 00:00:00 2001 From: Rory& Date: Mon, 15 Jul 2024 13:52:47 +0200 Subject: Working json canonicalisation --- .../LibMatrix.E2eeTestKit/Pages/CSTJTest.razor | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Utilities/LibMatrix.E2eeTestKit/Pages/CSTJTest.razor (limited to 'Utilities/LibMatrix.E2eeTestKit/Pages/CSTJTest.razor') diff --git a/Utilities/LibMatrix.E2eeTestKit/Pages/CSTJTest.razor b/Utilities/LibMatrix.E2eeTestKit/Pages/CSTJTest.razor new file mode 100644 index 0000000..0d01428 --- /dev/null +++ b/Utilities/LibMatrix.E2eeTestKit/Pages/CSTJTest.razor @@ -0,0 +1,39 @@ +@page "/CSTJTest" +@using System.Text.Json +@using System.Text.Json.Nodes +@using LibMatrix.Extensions + +Counter + +

Canonicalise JSON

+
+ + +
+
@JsonOutput
+ +@code { + private string _jsonInput = ""; + + private string JsonInput { + get => _jsonInput; + set { + _jsonInput = value; + try { + Console.WriteLine("Input updated"); + var obj = JsonSerializer.Deserialize(value); + Console.WriteLine("Deserialised"); + JsonOutput = CanonicalJsonSerializer.Serialize(obj); + Console.WriteLine("Serialised: " + JsonOutput ?? "null"); + } + catch (Exception e) { + JsonOutput = e.ToString(); + } + + StateHasChanged(); + } + } + + private string? JsonOutput { get; set; } + +} \ No newline at end of file -- cgit 1.4.1