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
3 changes: 2 additions & 1 deletion src/JQ/JQ.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using CliWrap;
using CliWrap.Buffered;
Expand Down Expand Up @@ -60,7 +61,7 @@ public static async Task<string> ExecuteAsync(string json, string query)

var jq = await Cli.Wrap(jqpath)
.WithArguments(["-r", query])
.WithStandardInputPipe(PipeSource.FromString(json))
.WithStandardInputPipe(PipeSource.FromString(json, Encoding.UTF8))
.WithValidation(CommandResultValidation.None)
.ExecuteBufferedAsync();

Expand Down
10 changes: 10 additions & 0 deletions src/Tests/JQTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Text;
using Devlooped;

namespace Tests;
Expand All @@ -18,4 +19,13 @@ public async Task SanityCheckAsync()
Assert.Equal("John", await JQ.ExecuteAsync(json, ".name"));
Assert.Equal("30", await JQ.ExecuteAsync(json, ".age"));
}

[Fact]
public async Task SupportsUTF8()
{
var json = await File.ReadAllTextAsync("sample.json", Encoding.UTF8);
var query = await JQ.ExecuteAsync(json, "[.itemListElement[].item]");

Assert.NotEmpty(query);
}
}
16 changes: 15 additions & 1 deletion src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<None Remove="sample.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
Expand All @@ -24,6 +28,16 @@
<Using Include="Xunit" />
</ItemGroup>

<Import Project="../JQ/buildTransitive/Devlooped.JQ.props"/>
<Import Project="../JQ/buildTransitive/Devlooped.JQ.props" />

<ItemGroup>
<UpToDateCheck Remove="sample.json" />
</ItemGroup>

<ItemGroup>
<Content Include="sample.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>
Loading