From 81086ddc8e7253686de68b7640791a9090d0f191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sat, 24 Feb 2024 16:37:58 +0100 Subject: [PATCH] Remove remaining Newtonsoft referenes. --- .../Extensions/TestCaseUITestContextExtensions.cs | 4 ++-- Lombiq.JsonEditor/Views/JsonField.cshtml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lombiq.JsonEditor.Test.UI/Extensions/TestCaseUITestContextExtensions.cs b/Lombiq.JsonEditor.Test.UI/Extensions/TestCaseUITestContextExtensions.cs index 310353e..844569b 100644 --- a/Lombiq.JsonEditor.Test.UI/Extensions/TestCaseUITestContextExtensions.cs +++ b/Lombiq.JsonEditor.Test.UI/Extensions/TestCaseUITestContextExtensions.cs @@ -1,9 +1,9 @@ using Atata; using Lombiq.Tests.UI.Extensions; using Lombiq.Tests.UI.Services; -using Newtonsoft.Json.Linq; using OpenQA.Selenium; using Shouldly; +using System.Text.Json.Nodes; using System.Threading.Tasks; namespace Lombiq.JsonEditor.Tests.UI.Extensions; @@ -139,7 +139,7 @@ private static async Task TestTreeStyleModeAsync(this UITestContext context) private static void TestCodeStyleMode(this UITestContext context) { // This field is hidden, but its content reflects what's in the editor. - var editorContent = JObject + var editorContent = JsonNode .Parse(context.Get(By.XPath($"//input[@class='jsonEditor__input']").OfAnyVisibility()) .GetValue()); diff --git a/Lombiq.JsonEditor/Views/JsonField.cshtml b/Lombiq.JsonEditor/Views/JsonField.cshtml index 9e679a2..dc632a2 100644 --- a/Lombiq.JsonEditor/Views/JsonField.cshtml +++ b/Lombiq.JsonEditor/Views/JsonField.cshtml @@ -3,7 +3,7 @@ @{ var name = (Model.PartFieldDefinition.PartDefinition.Name + Model.PartFieldDefinition.Name).ToCamelCase(); - var jObject = JObject.Parse(Model.Value ?? "{}"); + var safeJson = JsonNode.Parse(Model.Value ?? "{}")?.ToString() ?? "{}"; } @* This exposes the field value to the client JavaScript. Re-parsing the JSON into JObject ensures that there is no @@ -11,5 +11,5 @@