diff --git a/src/LitJson/JsonMapper.cs b/src/LitJson/JsonMapper.cs index 38d68a7..a674191 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 8a3421f..64e9dcb 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); }