@@ -8,8 +8,8 @@ namespace Discord.Serialization.Json.Converters | |||
{ | |||
if (isTopLevel) | |||
reader.Read(); | |||
if (reader.ValueType != JsonValueType.Number) | |||
throw new SerializationException("Bad input, expected Number"); | |||
if (reader.ValueType != JsonValueType.Number && reader.ValueType != JsonValueType.String) | |||
throw new SerializationException("Bad input, expected Number or String"); | |||
return reader.ParseSingle(); | |||
} | |||
public void Write(PropertyMap map, JsonWriter writer, float value, bool isTopLevel) | |||
@@ -27,8 +27,8 @@ namespace Discord.Serialization.Json.Converters | |||
{ | |||
if (isTopLevel) | |||
reader.Read(); | |||
if (reader.ValueType != JsonValueType.Number) | |||
throw new SerializationException("Bad input, expected Number"); | |||
if (reader.ValueType != JsonValueType.Number && reader.ValueType != JsonValueType.String) | |||
throw new SerializationException("Bad input, expected Number or String"); | |||
return reader.ParseDouble(); | |||
} | |||
public void Write(PropertyMap map, JsonWriter writer, double value, bool isTopLevel) | |||
@@ -46,8 +46,8 @@ namespace Discord.Serialization.Json.Converters | |||
{ | |||
if (isTopLevel) | |||
reader.Read(); | |||
if (reader.ValueType != JsonValueType.Number) | |||
throw new SerializationException("Bad input, expected Number"); | |||
if (reader.ValueType != JsonValueType.Number && reader.ValueType != JsonValueType.String) | |||
throw new SerializationException("Bad input, expected Number or String"); | |||
return reader.ParseDecimal(); | |||
} | |||
public void Write(PropertyMap map, JsonWriter writer, decimal value, bool isTopLevel) | |||
@@ -8,8 +8,8 @@ namespace Discord.Serialization.Json.Converters | |||
{ | |||
if (isTopLevel) | |||
reader.Read(); | |||
if (reader.ValueType != JsonValueType.Number) | |||
throw new SerializationException("Bad input, expected Number"); | |||
if (reader.ValueType != JsonValueType.Number && reader.ValueType != JsonValueType.String) | |||
throw new SerializationException("Bad input, expected Number or String"); | |||
return reader.ParseInt8(); | |||
} | |||
public void Write(PropertyMap map, JsonWriter writer, sbyte value, bool isTopLevel) | |||
@@ -27,8 +27,8 @@ namespace Discord.Serialization.Json.Converters | |||
{ | |||
if (isTopLevel) | |||
reader.Read(); | |||
if (reader.ValueType != JsonValueType.Number) | |||
throw new SerializationException("Bad input, expected Number"); | |||
if (reader.ValueType != JsonValueType.Number && reader.ValueType != JsonValueType.String) | |||
throw new SerializationException("Bad input, expected Number or String"); | |||
return reader.ParseInt16(); | |||
} | |||
public void Write(PropertyMap map, JsonWriter writer, short value, bool isTopLevel) | |||
@@ -46,8 +46,8 @@ namespace Discord.Serialization.Json.Converters | |||
{ | |||
if (isTopLevel) | |||
reader.Read(); | |||
if (reader.ValueType != JsonValueType.Number) | |||
throw new SerializationException("Bad input, expected Number"); | |||
if (reader.ValueType != JsonValueType.Number && reader.ValueType != JsonValueType.String) | |||
throw new SerializationException("Bad input, expected Number or String"); | |||
return reader.ParseInt32(); | |||
} | |||
public void Write(PropertyMap map, JsonWriter writer, int value, bool isTopLevel) | |||
@@ -65,8 +65,8 @@ namespace Discord.Serialization.Json.Converters | |||
{ | |||
if (isTopLevel) | |||
reader.Read(); | |||
if (reader.ValueType != JsonValueType.String) | |||
throw new SerializationException("Bad input, expected String"); | |||
if (reader.ValueType != JsonValueType.Number && reader.ValueType != JsonValueType.String) | |||
throw new SerializationException("Bad input, expected Number or String"); | |||
return reader.ParseInt64(); | |||
} | |||
public void Write(PropertyMap map, JsonWriter writer, long value, bool isTopLevel) | |||
@@ -8,8 +8,8 @@ namespace Discord.Serialization.Json.Converters | |||
{ | |||
if (isTopLevel) | |||
reader.Read(); | |||
if (reader.ValueType != JsonValueType.Number) | |||
throw new SerializationException("Bad input, expected Number"); | |||
if (reader.ValueType != JsonValueType.Number && reader.ValueType != JsonValueType.String) | |||
throw new SerializationException("Bad input, expected Number or String"); | |||
return reader.ParseUInt8(); | |||
} | |||
public void Write(PropertyMap map, JsonWriter writer, byte value, bool isTopLevel) | |||
@@ -27,8 +27,8 @@ namespace Discord.Serialization.Json.Converters | |||
{ | |||
if (isTopLevel) | |||
reader.Read(); | |||
if (reader.ValueType != JsonValueType.Number) | |||
throw new SerializationException("Bad input, expected Number"); | |||
if (reader.ValueType != JsonValueType.Number && reader.ValueType != JsonValueType.String) | |||
throw new SerializationException("Bad input, expected Number or String"); | |||
return reader.ParseUInt16(); | |||
} | |||
public void Write(PropertyMap map, JsonWriter writer, ushort value, bool isTopLevel) | |||
@@ -46,8 +46,8 @@ namespace Discord.Serialization.Json.Converters | |||
{ | |||
if (isTopLevel) | |||
reader.Read(); | |||
if (reader.ValueType != JsonValueType.Number) | |||
throw new SerializationException("Bad input, expected Number"); | |||
if (reader.ValueType != JsonValueType.Number && reader.ValueType != JsonValueType.String) | |||
throw new SerializationException("Bad input, expected Number or String"); | |||
return reader.ParseUInt32(); | |||
} | |||
public void Write(PropertyMap map, JsonWriter writer, uint value, bool isTopLevel) | |||
@@ -65,8 +65,8 @@ namespace Discord.Serialization.Json.Converters | |||
{ | |||
if (isTopLevel) | |||
reader.Read(); | |||
if (reader.ValueType != JsonValueType.String) | |||
throw new SerializationException("Bad input, expected String"); | |||
if (reader.ValueType != JsonValueType.Number && reader.ValueType != JsonValueType.String) | |||
throw new SerializationException("Bad input, expected Number or String"); | |||
return reader.ParseUInt64(); | |||
} | |||
public void Write(PropertyMap map, JsonWriter writer, ulong value, bool isTopLevel) | |||