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

Logic v3.1.2 #320

Merged
merged 4 commits into from
Aug 16, 2022
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
21 changes: 20 additions & 1 deletion JsonLogic.Tests/GithubTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.Json;
using System.Globalization;
using System.Text.Json;
using System.Text.Json.Nodes;
using Json.Logic.Rules;
using Json.More;
Expand Down Expand Up @@ -138,4 +139,22 @@ public void Issue313_VarEqualsNull()

Assert.IsTrue(result.IsEquivalentTo(true));
}

[Test]
public void Issue318_CanParseStringAsFloatingPointNumberInAnyCulture()
{
var culture = CultureInfo.CurrentCulture;

try
{
CultureInfo.CurrentCulture = new CultureInfo("de-AT");
var number = JsonValue.Create("3.14").Numberify();

Assert.AreEqual(3.14d, number);
}
finally
{
CultureInfo.CurrentCulture = culture;
}
}
}
4 changes: 2 additions & 2 deletions JsonLogic/JsonLogic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<PackageTags>json logic json-logic jsonlogic</PackageTags>
<PackageReleaseNotes>https://gregsdennis.github.io/json-everything/release-notes/json-logic.html</PackageReleaseNotes>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>3.1.1</Version>
<Version>3.1.2</Version>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<FileVersion>3.1.1.0</FileVersion>
<FileVersion>3.1.2.0</FileVersion>
<DocumentationFile>JsonLogic.xml</DocumentationFile>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
Expand Down
3 changes: 2 additions & 1 deletion JsonLogic/JsonNodeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.Json.Nodes;
using Json.More;
Expand Down Expand Up @@ -93,7 +94,7 @@ public static bool IsTruthy(this JsonNode? node)

if (node is not JsonValue value) return null;

if (value.TryGetValue(out string? s)) return decimal.TryParse(s, out var d) ? d : null;
if (value.TryGetValue(out string? s)) return decimal.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out var d) ? d : null;

if (value.TryGetValue(out bool b)) return b ? 1 : 0;

Expand Down
6 changes: 5 additions & 1 deletion json-everything.net/wwwroot/md/release-notes/json-logic.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# 3.1.0 (no PR)
# [3.1.2](https://github.com/gregsdennis/json-everything/pull/320)

[#318](https://github.com/gregsdennis/json-everything/issues/318)/[#319](https://github.com/gregsdennis/json-everything/pull/319) - Conversions to numbers shouldn't be culture-dependent. Thanks to [@warappa](https://github.com/warappa) for reporting and fixing this.

# 3.1.1 (no PR)

[#313](https://github.com/gregsdennis/json-everything/issues/313) - Deserialization of nulls resulted in an actual null rule instead of a variable rule with a null value. Thanks to [@jhspinpanel](https://github.com/jhspinpanel) for reporting this.

Expand Down