Skip to content

Commit

Permalink
Merge pull request #320 from gregsdennis/logic-v3.1.2
Browse files Browse the repository at this point in the history
Logic v3.1.2
  • Loading branch information
gregsdennis committed Aug 16, 2022
2 parents c991aa2 + 089018f commit 102b671
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
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

0 comments on commit 102b671

Please sign in to comment.