Stream Chat Unreal SDK
Loading...
Searching...
No Matches
JsonObjectDeserialization.h
1// Copyright 2022 Stream.IO, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6
7class FJsonValue;
8class FJsonObject;
9
15{
25STREAMJSON_API bool JsonObjectToUStruct(const TSharedRef<FJsonObject>& JsonObject, const UStruct* StructDefinition, void* OutStruct);
26
35template <typename OutStructType>
36bool JsonObjectToUStruct(const TSharedRef<FJsonObject>& JsonObject, OutStructType* OutStruct)
37{
38 const bool bSuccess = JsonObjectToUStruct(JsonObject, OutStructType::StaticStruct(), OutStruct);
39 return bSuccess;
40}
41
51bool JsonAttributesToUStruct(const TMap<FString, TSharedPtr<FJsonValue>>& JsonAttributes, const UStruct* StructDefinition, void* OutStruct);
52
61STREAMJSON_API bool JsonObjectStringToJsonObject(const FString& JsonString, TSharedPtr<FJsonObject>& OutObject);
62
71template <typename OutStructType>
72bool JsonObjectStringToUStruct(const FString& JsonString, OutStructType* OutStruct)
73{
74 TSharedPtr<FJsonObject> JsonObject;
76 {
77 UE_LOG(LogTemp, Warning, TEXT("JsonObjectStringToUStruct - Unable to parse json=[%s]"), *JsonString);
78 return false;
79 }
81 {
82 UE_LOG(LogTemp, Warning, TEXT("JsonObjectStringToUStruct - Unable to deserialize. json=[%s]"), *JsonString);
83 return false;
84 }
85 return true;
86}
87
88STREAMJSON_API bool ParseIso8601(const TCHAR* DateTimeString, FDateTime& OutDateTime);
89}; // namespace JsonObjectDeserialization
Handles converting Json objects to UStructs.
Definition: JsonObjectDeserialization.h:15
bool JsonObjectStringToUStruct(const FString &JsonString, OutStructType *OutStruct)
Converts from a json string containing an object to a UStruct.
Definition: JsonObjectDeserialization.h:72
STREAMJSON_API bool JsonObjectStringToJsonObject(const FString &JsonString, TSharedPtr< FJsonObject > &OutObject)
Converts from a json string containing an object to a UStruct.
Definition: JsonObjectDeserialization.cpp:708
bool JsonAttributesToUStruct(const TMap< FString, TSharedPtr< FJsonValue > > &JsonAttributes, const UStruct *StructDefinition, void *OutStruct)
Converts a set of json attributes (possibly from within a JsonObject) to a UStruct,...
Definition: JsonObjectDeserialization.cpp:700
STREAMJSON_API bool JsonObjectToUStruct(const TSharedRef< FJsonObject > &JsonObject, const UStruct *StructDefinition, void *OutStruct)
Converts from a Json Object to a UStruct, using importText.
Definition: JsonObjectDeserialization.cpp:695
Conversion to and from dynamic JSON objects.
Definition: StreamJson.h:16