Closed fungiboletus closed 7 years ago
It seems to be a bug from Unreal and not VaRest.
It works with double
though.
FString jsonDocument(TEXT("{\"Id\":16842749}"));
TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
TSharedRef< TJsonReader<> > JsonReader = TJsonReaderFactory<>::Create(jsonDocument);
if (FJsonSerializer::Deserialize(JsonReader, JsonObject) && JsonObject.IsValid())
{
float numberFloat = JsonObject->GetNumberField(FString(TEXT("Id")));
double numberDouble = JsonObject->GetNumberField(FString(TEXT("Id")));
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow,
FString::Printf(TEXT("Id float: %f\nId double: %f"),
numberFloat, numberDouble));
}
Ok, so it's a float
issue. Float are not good to represent big numbers.
Unreal only implements the double, and VaRest casts it to float, because you can't use double in blueprints.
Could VaRest implement a int32 GetIntegerField
?
Yep, it's a float issue.
Thanks for pull request! :)
Hi,
Using VaRest 1.1-r16, it seems that a wrong number is sometimes returned.
The JSON string is
{"Id":16842749}
And 16842749 != 16842748 indeed.