Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes #366

Merged
merged 4 commits into from
Jan 16, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion JsonPath/CountFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class CountFunction : IPathFunctionDefinition
/// <summary>
/// Gets the function name.
/// </summary>
public string Name => "length";
public string Name => "count";

/// <summary>
/// The minimum argument count accepted by the function.
Expand Down
5 changes: 4 additions & 1 deletion JsonPath/FunctionRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public static class FunctionRepository
static FunctionRepository()
{
Register(new LengthFunction());
Register(new CountFunction());
Register(new MatchFunction());
Register(new SearchFunction());
}

/// <summary>
Expand Down Expand Up @@ -53,7 +56,7 @@ public static void Unregister(string name)
/// <param name="name">A function name.</param>
/// <param name="function">The function, if found; otherwise null.</param>
/// <returns>True if found; otherwise false.</returns>
public static bool TryGet(string name, [NotNullWhen(true)]out IPathFunctionDefinition? function)
public static bool TryGet(string name, [NotNullWhen(true)] out IPathFunctionDefinition? function)
{
return _functions.TryGetValue(name, out function);
}
Expand Down
4 changes: 2 additions & 2 deletions JsonPath/JsonPath.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<PackageIcon>json-logo-256.png</PackageIcon>
<PackageTags>json-path jsonpath query path json</PackageTags>
<PackageReleaseNotes>Release notes can be found on [GitHub](https://github.com/gregsdennis/json-everything/blob/master/json-everything.net/wwwroot/md/release-notes/json-path.md) and https://json-everything.net/json-path</PackageReleaseNotes>
<Version>0.3.1</Version>
<FileVersion>0.3.1.0</FileVersion>
<Version>0.3.2</Version>
<FileVersion>0.3.2.0</FileVersion>
<AssemblyVersion>0.3.0.0</AssemblyVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<DocumentationFile>JsonPath.Net.xml</DocumentationFile>
Expand Down
9 changes: 4 additions & 5 deletions JsonPath/MatchFunction.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Nodes;
using System.Text.RegularExpressions;
Expand All @@ -15,17 +14,17 @@ public class MatchFunction : IPathFunctionDefinition
/// <summary>
/// Gets the function name.
/// </summary>
public string Name => "length";
public string Name => "match";

/// <summary>
/// The minimum argument count accepted by the function.
/// </summary>
public int MinArgumentCount => 1;
public int MinArgumentCount => 2;

/// <summary>
/// The maximum argument count accepted by the function.
/// </summary>
public int MaxArgumentCount => 1;
public int MaxArgumentCount => 2;

/// <summary>
/// Evaluates the function.
Expand Down
6 changes: 3 additions & 3 deletions JsonPath/SearchFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ public class SearchFunction : IPathFunctionDefinition
/// <summary>
/// Gets the function name.
/// </summary>
public string Name => "length";
public string Name => "search";

/// <summary>
/// The minimum argument count accepted by the function.
/// </summary>
public int MinArgumentCount => 1;
public int MinArgumentCount => 2;

/// <summary>
/// The maximum argument count accepted by the function.
/// </summary>
public int MaxArgumentCount => 1;
public int MaxArgumentCount => 2;

/// <summary>
/// Evaluates the function.
Expand Down
2 changes: 1 addition & 1 deletion JsonSchema.UniqueKeys/JsonSchema.UniqueKeys.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<DocumentationFile>JsonSchema.Net.UniqueKeys.xml</DocumentationFile>
<LangVersion>latest</LangVersion>
<Version>2.1.0-beta1</Version>
<Version>2.1.0-beta2</Version>
<FileVersion>2.1.0.0</FileVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<IncludeSymbols>true</IncludeSymbols>
Expand Down
2 changes: 1 addition & 1 deletion JsonSchema.UniqueKeys/UniqueKeysKeyword.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void Evaluate(EvaluationContext context)
if (matchedIndexPairs.Any())
{
var pairs = string.Join(", ", matchedIndexPairs.Select(d => $"({d.Item1}, {d.Item2})"));
context.LocalResult.Fail(Name, ErrorMessages.UniqueItems, ("pairs", pairs));
context.LocalResult.Fail(Name, ErrorMessages.UniqueItems, ("duplicates", pairs));
}

context.ExitKeyword(Name);
Expand Down
4 changes: 4 additions & 0 deletions json-everything.net/wwwroot/md/release-notes/json-path.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# [0.3.2](https://github.com/gregsdennis/json-everything/pull/366)

[#364](https://github.com/gregsdennis/json-everything/issues/364) - `count()`, `match()`, and `search()` functions are not registered and so cannot be parsed. Thanks to [@amis92](https://github.com/amis92) for finding and reporting this.

# [0.3.1](https://github.com/gregsdennis/json-everything/commit/3248441c00dd97cf4a8c66fff6b2462682a3bb8e)

Fixed an issue in `search` and `match` function evaluation.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# [2.1.0 (beta 2)](https://github.com/gregsdennis/json-everything/pull/366)

[#288](https://github.com/gregsdennis/json-everything/issues/288) - `duplicates` token in error message was not being replaced with the appropriate value. Thanks to [@szilajka](https://github.com/szilajka) for finding and reporting this.

# [2.1.0 (beta 1)](https://github.com/gregsdennis/json-everything/pull/326)

Updated to use JsonSchema.Net v4.
Expand Down