Permalink
Browse files

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/monotouch-2-0/mcs/; revision=154611
  • Loading branch information...
1 parent 2d306a1 commit 62121afbb28f0b62f100ec9a942d10c5e0f4814f @migueldeicaza migueldeicaza committed Apr 1, 2010
Showing with 25 additions and 13 deletions.
  1. +12 −0 mcs/class/System.Json/System.Json/ChangeLog
  2. +13 −13 mcs/class/System.Json/System.Json/JsonValue.cs
@@ -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
@@ -253,70 +253,70 @@ string DoEscapeString (StringBuilder sb, string src, int cur)
{
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 @@ string DoEscapeString (StringBuilder sb, string src, int cur)
{
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)

0 comments on commit 62121af

Please sign in to comment.