diff options
author | Geoff Norton <grompf@sublimeintervention.com> | 2010-04-01 10:38:50 +0400 |
---|---|---|
committer | Geoff Norton <grompf@sublimeintervention.com> | 2010-04-01 10:38:50 +0400 |
commit | 7aab767a0551df6f2f0e8b8f7533c087a91f1768 (patch) | |
tree | 56a8a9e98bbde547201786ed64a588f4a5a282c5 /mcs/class | |
parent | 482a8d2725e3183d755994c96430c18316b6f407 (diff) |
2009-08-13 Atsushi Enomoto <atsushi@ximian.com>
* Makefile : update profile check.
2008-06-10 Atsushi Enomoto <atsushi@ximian.com>
* System.Json.dll.sources, Makefile : initial checkin.
svn path=/branches/mono-2-6/mcs/; revision=154612
Diffstat (limited to 'mcs/class')
-rw-r--r-- | mcs/class/System.Json/System.Json/ChangeLog | 12 | ||||
-rw-r--r-- | mcs/class/System.Json/System.Json/JsonValue.cs | 26 |
2 files changed, 25 insertions, 13 deletions
diff --git a/mcs/class/System.Json/System.Json/ChangeLog b/mcs/class/System.Json/System.Json/ChangeLog index a89f26758ae..b1b55dea773 100644 --- a/mcs/class/System.Json/System.Json/ChangeLog +++ b/mcs/class/System.Json/System.Json/ChangeLog @@ -1,3 +1,15 @@ +2010-04-01 Miguel de Icaza <miguel@novell.com> + + * JsonValue.cs: We need to use Convert.ToXXXX for numbers as we + always end up reporting the value JsonType.Number regardless of + the underlying storage (int, long or decimal). The parser + picks the best storage suitable for the data, and can end up using + "ints" for values that sometimes use longs. + + This causes problems when derefercing the data for example, if you + have an int and try to get it out as a long you end up with an + invalid cast exception. + 2010-02-18 Atsushi Enomoto <atsushi@ximian.com> * JsonValue.cs : fix string escaping, it was giving wrong output diff --git a/mcs/class/System.Json/System.Json/JsonValue.cs b/mcs/class/System.Json/System.Json/JsonValue.cs index 9e4bfd589ea..6d076a8838f 100644 --- a/mcs/class/System.Json/System.Json/JsonValue.cs +++ b/mcs/class/System.Json/System.Json/JsonValue.cs @@ -253,70 +253,70 @@ namespace System.Json { if (value == null) throw new ArgumentNullException ("value"); - return (bool) ((JsonPrimitive) value).Value; + return Convert.ToBoolean (((JsonPrimitive) value).Value); } public static implicit operator byte (JsonValue value) { if (value == null) throw new ArgumentNullException ("value"); - return (byte) ((JsonPrimitive) value).Value; + return Convert.ToByte (((JsonPrimitive) value).Value); } public static implicit operator char (JsonValue value) { if (value == null) throw new ArgumentNullException ("value"); - return (char) ((JsonPrimitive) value).Value; + return Convert.ToChar (((JsonPrimitive) value).Value); } public static implicit operator decimal (JsonValue value) { if (value == null) throw new ArgumentNullException ("value"); - return (decimal) ((JsonPrimitive) value).Value; + return Convert.ToDecimal (((JsonPrimitive) value).Value); } public static implicit operator double (JsonValue value) { if (value == null) throw new ArgumentNullException ("value"); - return (double) ((JsonPrimitive) value).Value; + return Convert.ToDouble (((JsonPrimitive) value).Value); } public static implicit operator float (JsonValue value) { if (value == null) throw new ArgumentNullException ("value"); - return (float) ((JsonPrimitive) value).Value; + return Convert.ToSingle (((JsonPrimitive) value).Value); } public static implicit operator int (JsonValue value) { if (value == null) throw new ArgumentNullException ("value"); - return (int) ((JsonPrimitive) value).Value; + return Convert.ToInt32 (((JsonPrimitive) value).Value); } public static implicit operator long (JsonValue value) { if (value == null) throw new ArgumentNullException ("value"); - return (long) ((JsonPrimitive) value).Value; + return Convert.ToInt64 (((JsonPrimitive) value).Value); } public static implicit operator sbyte (JsonValue value) { if (value == null) throw new ArgumentNullException ("value"); - return (sbyte) ((JsonPrimitive) value).Value; + return Convert.ToSByte (((JsonPrimitive) value).Value); } public static implicit operator short (JsonValue value) { if (value == null) throw new ArgumentNullException ("value"); - return (short) ((JsonPrimitive) value).Value; + return Convert.ToInt16 (((JsonPrimitive) value).Value); } public static implicit operator string (JsonValue value) @@ -330,21 +330,21 @@ namespace System.Json { if (value == null) throw new ArgumentNullException ("value"); - return (uint) ((JsonPrimitive) value).Value; + return Convert.ToUInt16 (((JsonPrimitive) value).Value); } public static implicit operator ulong (JsonValue value) { if (value == null) throw new ArgumentNullException ("value"); - return (ulong) ((JsonPrimitive) value).Value; + return Convert.ToUInt64(((JsonPrimitive) value).Value); } public static implicit operator ushort (JsonValue value) { if (value == null) throw new ArgumentNullException ("value"); - return (ushort) ((JsonPrimitive) value).Value; + return Convert.ToUInt16 (((JsonPrimitive) value).Value); } public static implicit operator DateTime (JsonValue value) |