Skip to content

Instantly share code, notes, and snippets.

@migueldeicaza
Created April 1, 2010 06:36
Show Gist options
  • Save migueldeicaza/351469 to your computer and use it in GitHub Desktop.
Save migueldeicaza/351469 to your computer and use it in GitHub Desktop.
Index: System.Json/JsonValue.cs
===================================================================
--- System.Json/JsonValue.cs (revision 154608)
+++ System.Json/JsonValue.cs (working copy)
@@ -253,70 +253,70 @@
{
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 @@
{
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment