diff --git a/ln.json.tests/JSONTests.cs b/ln.json.tests/JSONTests.cs index 23dc3c0..02ea47e 100644 --- a/ln.json.tests/JSONTests.cs +++ b/ln.json.tests/JSONTests.cs @@ -87,8 +87,6 @@ namespace ln.json.tests TestEnumSerialization(testEnum3.C); TestEnumSerialization(testEnum3.D); TestEnumSerialization(testEnum3.E); - - } bool TestEnumSerialization(object enumValue) @@ -105,7 +103,15 @@ namespace ln.json.tests return true; } - + [Test] + public void TestMapper() + { + byte b = 0x80; + Assert.IsTrue(JSONMapper.DefaultMapper.Serialize(b, out JSONValue jsonByte)); + JSONMapper.DefaultMapper.Deserialize(jsonByte, typeof(byte), out object b2); + Assert.AreEqual(b,b2); + Assert.AreEqual(b.GetType(), b2.GetType()); + } } } \ No newline at end of file diff --git a/ln.json/mapping/JSONMapper.cs b/ln.json/mapping/JSONMapper.cs index f5cfa11..0517c55 100644 --- a/ln.json/mapping/JSONMapper.cs +++ b/ln.json/mapping/JSONMapper.cs @@ -259,7 +259,7 @@ namespace ln.json.mapping { DefaultMapper.Add(new JSONMapping( typeof(byte), - (JSONMapper arg1, object arg2) => new JSONNumber((int)arg2), + (JSONMapper arg1, object arg2) => new JSONNumber((int)(byte)arg2), (JSONMapper arg1, JSONValue arg2) => Decimal.ToByte(((JSONNumber)arg2).Decimal) )); DefaultMapper.Add(new JSONMapping(