diff --git a/src/Confix.Tool/src/Confix.Library/Output/JsonNodeOutputFormatter.cs b/src/Confix.Tool/src/Confix.Library/Output/JsonNodeOutputFormatter.cs index 941e5b8..b7bd3bb 100644 --- a/src/Confix.Tool/src/Confix.Library/Output/JsonNodeOutputFormatter.cs +++ b/src/Confix.Tool/src/Confix.Library/Output/JsonNodeOutputFormatter.cs @@ -1,3 +1,5 @@ +using System.Text.Encodings.Web; +using System.Text.Json; using System.Text.Json.Nodes; using Confix.Tool.Commands.Logging; using Confix.Tool.Reporting; @@ -6,6 +8,11 @@ namespace Confix.Tool.Commands.Configuration; public sealed class JsonNodeOutputFormatter : IOutputFormatter { + private static readonly JsonSerializerOptions _options = new() + { + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping + }; + /// public bool CanHandle(OutputFormat format, JsonNode value) => format == OutputFormat.Json; @@ -13,6 +20,6 @@ public bool CanHandle(OutputFormat format, JsonNode value) /// public Task FormatAsync(OutputFormat format, JsonNode value) { - return Task.FromResult(value.ToJsonString()); + return Task.FromResult(value.ToJsonString(_options)); } } diff --git a/src/Confix.Tool/src/Confix.Library/Pipelines/Variable/VariableGetPipeline.cs b/src/Confix.Tool/src/Confix.Library/Pipelines/Variable/VariableGetPipeline.cs index e2ef8dd..518fce3 100644 --- a/src/Confix.Tool/src/Confix.Library/Pipelines/Variable/VariableGetPipeline.cs +++ b/src/Confix.Tool/src/Confix.Library/Pipelines/Variable/VariableGetPipeline.cs @@ -38,7 +38,7 @@ private static async Task InvokeAsync(IMiddlewareContext context) var result = await resolver .ResolveOrThrowAsync(variablePath, variableContext); - context.Logger.PrintVariableResolved(variablePath, result.ToJsonString()); + context.Logger.PrintVariableResolved(variablePath, result.ToString()); context.SetOutput(result); }