-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
May be it is not very probable but what if the server sends a number that starts with a '+' sign?
// Is it a number?
if (**data == L'-' || (**data >= L'0' && **data <= L'9'))
{
......
should also expect a '+'
Additionally I would like to distinguish double numbers from integer numbers.
You put them all into a double variable.
I would prefer a double variable for floating point numbers and an __int64 variable for integer numbers.
Then there should be the functions:
bool JSONValue::IsLong()
{
return type == JSONType_Long;
}
bool JSONValue::IsDouble()
{
return type == JSONType_Double;
}
bool JSONValue::IsNumber()
{
return type == JSONType_Long || type == JSONType_Double;
}
and
__int64 JSONValue::AsLong()
{
assert(type == JSONType_Long);
return long_value;
}
double JSONValue::AsDouble()
{
assert(type == JSONType_Double);
return double_value;
}
double JSONValue::AsNumber()
{
switch (type)
{
case JSONType_Double: return double_value;
case JSONType_Long: return (double)long_value;
default:
assert(false);
return 0;
}
}
Metadata
Metadata
Assignees
Labels
No labels