Skip to content

Commit

Permalink
Remove remaining Newtonsoft referenes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahelsaig committed Feb 24, 2024
1 parent 4f0d042 commit 81086dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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());

Expand Down
4 changes: 2 additions & 2 deletions Lombiq.JsonEditor/Views/JsonField.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

@{
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
dangerous content (such as JS code injection) in there, so it's safe to pass the value into Html.Raw(). *@
<script>
if (!('JsonField' in window) || !window.JsonField) window.JsonField = {};
var fieldName = @name.JsonHtmlContent();
window.JsonField[fieldName] = @Html.Raw(jObject.ToString());
window.JsonField[fieldName] = @Html.Raw(safeJson);
</script>

0 comments on commit 81086dd

Please sign in to comment.