Lesson 61 - Parsing an HTTP Response
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include "HttpModule.h"
|
||||
#include "Data/API/APIData.h"
|
||||
#include "GameplayTags/DedicatedServerTags.h"
|
||||
#include "Interfaces/IHttpResponse.h"
|
||||
|
||||
|
||||
void UAPITestManager::ListFleetsButtonClicked()
|
||||
{
|
||||
@@ -25,5 +27,21 @@ void UAPITestManager::ListFleetsButtonClicked()
|
||||
|
||||
void UAPITestManager::ListFleets_Response(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "List Fleets Response Received");
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "List Fleets Response Received");
|
||||
|
||||
TSharedPtr<FJsonObject> JsonObject;
|
||||
TSharedRef<TJsonReader<>> JsonReader = TJsonReaderFactory<>::Create(Response->GetContentAsString());
|
||||
|
||||
if (FJsonSerializer::Deserialize(JsonReader, JsonObject))
|
||||
{
|
||||
if (JsonObject->HasField(TEXT("FleetIds")))
|
||||
{
|
||||
for (TSharedPtr<FJsonValue> Fleet : JsonObject->GetArrayField(TEXT("FleetIds")))
|
||||
{
|
||||
FString FleetString = Fleet->AsString();
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FleetString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user