Skip to content

Commit 505c6cb

Browse files
committed
- Fixed #224
1 parent afd8090 commit 505c6cb

File tree

9 files changed

+27
-3
lines changed

9 files changed

+27
-3
lines changed

NetJSON.Tests/SerializeTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,6 +1704,30 @@ public void ShouldNotFailWhenUsingNegativeIntEnumWithValue()
17041704

17051705
Assert.AreEqual((int)data.LongEnum, (int)obj.LongEnum);
17061706
}
1707+
1708+
1709+
[TestMethod]
1710+
public void ShouldNotFailFloatConvert()
1711+
{
1712+
var testFloat = new TestFloatClass
1713+
{
1714+
IntValue = 10,
1715+
FloatValue = 10.5f,
1716+
StringValue = "10"
1717+
};
1718+
1719+
var json = NetJSON.Serialize(testFloat);
1720+
var testFloatData = NetJSON.Deserialize<TestFloatClass>(json);
1721+
1722+
Assert.AreEqual(10.5f, testFloatData.FloatValue);
1723+
}
1724+
}
1725+
1726+
public class TestFloatClass
1727+
{
1728+
public int IntValue { get; set; }
1729+
public float FloatValue { get; set; }
1730+
public string StringValue { get; set; }
17071731
}
17081732

17091733
public class SimpleClass : ISimpleClass

NetJSON/NetJSON.Internals.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ internal unsafe static string GetNonStringValue(char* ptr, ref int index) {
748748
index += 4;
749749
return null;
750750
}
751-
else if(!(((int)current) >= 48 && ((int)current) <= 57) && current != '-')
751+
else if(!(((int)current) >= 48 && ((int)current) <= 57) && current != '-' && current != '.')
752752
{
753753
value = new string(ptr, startIndex, index - startIndex - indexDiff);
754754
--index;

NetJSON/NetJSON.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<id>NetJSON</id>
55
<title>NetJSON</title>
66
<tags>json json-serializer javascript JSON serializer binary</tags>
7-
<version>1.3.1</version>
7+
<version>1.3.2</version>
88
<authors>TJ Bakre</authors>
99
<description>Faster than Any Binary?</description>
1010
<releaseNotes>
11-
- Fixed issue with negative enum values
11+
- Fixed issue with floating point conversion during deserialization
1212
</releaseNotes>
1313
<language>en-US</language>
1414
<licenseUrl>https://github.com/rpgmaker/NetJSON/blob/master/LICENSE.text</licenseUrl>

NetJSON/lib/net35/NetJSON.dll

0 Bytes
Binary file not shown.

NetJSON/lib/net40/NetJSON.dll

0 Bytes
Binary file not shown.

NetJSON/lib/net462/NetJSON.dll

0 Bytes
Binary file not shown.

NetJSON/lib/net472/NetJSON.dll

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)