From 5c7464139af4f3a77826b2d9a7af413c5dc8752d Mon Sep 17 00:00:00 2001 From: yanakend Date: Sat, 18 Jul 2015 21:26:26 +0900 Subject: [PATCH] Fix invalid cast long to string --- src/LitJson/JsonMapper.cs | 2 +- test/JsonMapperTest.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/LitJson/JsonMapper.cs b/src/LitJson/JsonMapper.cs index 38d68a77..a674191a 100644 --- a/src/LitJson/JsonMapper.cs +++ b/src/LitJson/JsonMapper.cs @@ -755,7 +755,7 @@ private static void WriteValue (object obj, JsonWriter writer, if (obj is IDictionary) { writer.WriteObjectStart (); foreach (DictionaryEntry entry in (IDictionary) obj) { - writer.WritePropertyName ((string) entry.Key); + writer.WritePropertyName (entry.Key.ToString()); WriteValue (entry.Value, writer, writer_is_private, depth + 1); } diff --git a/test/JsonMapperTest.cs b/test/JsonMapperTest.cs index 8a3421fe..64e9dcbc 100644 --- a/test/JsonMapperTest.cs +++ b/test/JsonMapperTest.cs @@ -283,12 +283,12 @@ public void ExportDictionaryTest () hash.Add ("product", "ACME rocket skates"); hash.Add ("quantity", 5); hash.Add ("price", 45.95); + hash.Add (1L, "Cast long to string"); string expected = "{\"product\":\"ACME rocket skates\"," + - "\"quantity\":5,\"price\":45.95}"; + "\"quantity\":5,\"price\":45.95,\"1\":\"Cast long to string\"}"; string json = JsonMapper.ToJson (hash); - Assert.AreEqual (expected, json); }