Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -6,13 +8,18 @@ namespace Confix.Tool.Commands.Configuration;

public sealed class JsonNodeOutputFormatter : IOutputFormatter<JsonNode>
{
private static readonly JsonSerializerOptions _options = new()
{
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
};

/// <inheritdoc />
public bool CanHandle(OutputFormat format, JsonNode value)
=> format == OutputFormat.Json;

/// <inheritdoc />
public Task<string> FormatAsync(OutputFormat format, JsonNode value)
{
return Task.FromResult(value.ToJsonString());
return Task.FromResult(value.ToJsonString(_options));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading