Skip to content

Commit 8583f35

Browse files
committed
add simple string conversion from json object
- this was always missing from SIOJConvert
1 parent 27dec04 commit 8583f35

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

SocketIOClient.uplugin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"FileVersion": 3,
33
"Version": 1,
4-
"VersionName": "2.9.2",
4+
"VersionName": "2.9.3",
55
"EngineVersion": "5.5",
66
"FriendlyName": "Socket.IO Client",
77
"Description": "Real-time WebSocket networking via Socket.IO protocol usable from blueprints and c++.",

Source/SIOJson/Private/SIOJConvert.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,3 +1097,15 @@ void USIOJConvert::ReplaceJsonValueNamesWithMap(TSharedPtr<FJsonValue>& JsonValu
10971097
}
10981098
}
10991099
}
1100+
1101+
FString USIOJConvert::JsonObjectToString(TSharedPtr<FJsonObject> Object)
1102+
{
1103+
FString JsonString;
1104+
auto JsonWriter = TJsonWriterFactory<TCHAR, TCondensedJsonPrintPolicy<TCHAR>>::Create(&JsonString);
1105+
bool bSerialized = FJsonSerializer::Serialize(Object.ToSharedRef(), JsonWriter);
1106+
if (!bSerialized)
1107+
{
1108+
UE_LOG(LogTemp, Error, TEXT("Failed to stringify JSON object."));
1109+
}
1110+
return JsonString;
1111+
}

Source/SIOJson/Public/SIOJConvert.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ class SIOJSON_API USIOJConvert : public UObject
7272
static void SetTrimmedKeyMapForStruct(TSharedPtr<FTrimmedKeyMap>& InMap, UStruct* Struct);
7373
static void SetTrimmedKeyMapForProp(TSharedPtr<FTrimmedKeyMap>& InMap, FProperty* ArrayInnerProp);
7474
static void ReplaceJsonValueNamesWithMap(TSharedPtr<FJsonValue>& InValue, TSharedPtr<FTrimmedKeyMap> KeyMap);
75+
76+
//Simple object to string converter
77+
static FString JsonObjectToString(TSharedPtr<FJsonObject> Object);
7578
};
7679

7780

0 commit comments

Comments
 (0)