diff --git a/.editorconfig b/.editorconfig
index 8c36c97f..9935e9f3 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -2,3 +2,6 @@
# SA1623: Property summary documentation should match accessors
dotnet_diagnostic.SA1623.severity = suggestion
+
+# SA1101: Prefix local calls with this
+dotnet_diagnostic.SA1101.severity = none
diff --git a/src/LEGO.AsyncAPI.Readers/JsonHelper.cs b/src/LEGO.AsyncAPI.Readers/JsonHelper.cs
index 5f7fc584..49a54a55 100644
--- a/src/LEGO.AsyncAPI.Readers/JsonHelper.cs
+++ b/src/LEGO.AsyncAPI.Readers/JsonHelper.cs
@@ -4,15 +4,49 @@ namespace LEGO.AsyncAPI.Readers
{
using System;
using System.Globalization;
+ using System.IO;
+ using System.Text.Encodings.Web;
+ using System.Text.Json;
using System.Text.Json.Nodes;
using LEGO.AsyncAPI.Exceptions;
+ ///
+ /// Contains helper methods for working with Json
+ ///
internal static class JsonHelper
{
- public static string GetScalarValue(this JsonNode node)
+ private static readonly JsonWriterOptions WriterOptions;
+
+ static JsonHelper()
+ {
+ WriterOptions = new JsonWriterOptions()
+ {
+ Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
+ Indented = false,
+ MaxDepth = 1,
+ SkipValidation = true,
+ };
+ }
+
+ ///
+ /// Takes a and converts it into a string value.
+ ///
+ /// The node to convert.
+ /// The string value.
+ public static string GetScalarValue(this JsonValue jsonValue)
{
- var scalarNode = node is JsonValue value ? value : throw new AsyncApiException($"Expected scalar value");
- return Convert.ToString(scalarNode.GetValue