This class provides static utility functions for operating system related JSON operations.
More...
#include "OperatingSystemJsonStatics.h"
|
static bool | DoesFileExists (const FString &BaseFileNameWithoutExtension) |
| Checks if a file with the given base file name without extension exists.
|
|
static bool | DeleteFile (const FString &BaseFileNameWithoutExtension) |
| Deletes a file with the given base file name without extension.
|
|
static TSharedPtr< FJsonObject > | ReadJson (const FString &BaseFileNameWithoutExtension) |
| Reads the JSON contents of a file with the given base file name without extension.
|
|
static bool | WriteJson (const FString &BaseFileNameWithoutExtension, TSharedRef< FJsonObject > JsonObject) |
| Writes the JSON contents of the given JsonObject to a file with the specified base file name without extension.
|
|
template<typename T > |
static bool | ReadStructFromJson (const FString &BaseFileNameWithoutExtension, T &OutStruct) |
| Reads the JSON contents of a file with the given base file name without extension and converts it to a struct.
|
|
template<typename T > |
static bool | WriteStructToJson (const FString BaseFileNameWithoutExtension, const T &InStruct) |
| Writes the contents of a struct to a JSON file.
|
|
This class provides static utility functions for operating system related JSON operations.
◆ DeleteFile()
bool UOperatingSystemJsonStatics::DeleteFile |
( |
const FString & | BaseFileNameWithoutExtension | ) |
|
|
static |
Deletes a file with the given base file name without extension.
- Parameters
-
BaseFileNameWithoutExtension | The base file name without extension of the file to delete. |
- Returns
- True if the file was successfully deleted, false otherwise.
◆ DoesFileExists()
bool UOperatingSystemJsonStatics::DoesFileExists |
( |
const FString & | BaseFileNameWithoutExtension | ) |
|
|
static |
Checks if a file with the given base file name without extension exists.
- Parameters
-
BaseFileNameWithoutExtension | The base file name without extension. |
- Returns
- True if the file exists, false otherwise.
◆ ReadJson()
TSharedPtr< FJsonObject > UOperatingSystemJsonStatics::ReadJson |
( |
const FString & | BaseFileNameWithoutExtension | ) |
|
|
static |
Reads the JSON contents of a file with the given base file name without extension.
- Parameters
-
BaseFileNameWithoutExtension | The base file name without extension of the file to read. |
- Returns
- A shared pointer to the deserialized JSON object if reading and deserialization is successful, otherwise nullptr.
◆ ReadStructFromJson()
template<typename T >
static bool UOperatingSystemJsonStatics::ReadStructFromJson |
( |
const FString & | BaseFileNameWithoutExtension, |
|
|
T & | OutStruct ) |
|
inlinestatic |
Reads the JSON contents of a file with the given base file name without extension and converts it to a struct.
- Parameters
-
BaseFileNameWithoutExtension | The base file name without extension of the file to read. |
OutStruct | The output parameter that will receive the converted struct data. |
- Returns
- True if the file exists, the JSON object is successfully read, and the struct is successfully converted, false otherwise.
◆ WriteJson()
bool UOperatingSystemJsonStatics::WriteJson |
( |
const FString & | BaseFileNameWithoutExtension, |
|
|
TSharedRef< FJsonObject > | JsonObject ) |
|
static |
Writes the JSON contents of the given JsonObject to a file with the specified base file name without extension.
- Parameters
-
BaseFileNameWithoutExtension | The base file name without extension of the file to write. |
JsonObject | The JSON object to write to the file. |
- Returns
- True if the JSON object was successfully written to the file, false otherwise.
◆ WriteStructToJson()
template<typename T >
static bool UOperatingSystemJsonStatics::WriteStructToJson |
( |
const FString | BaseFileNameWithoutExtension, |
|
|
const T & | InStruct ) |
|
inlinestatic |
Writes the contents of a struct to a JSON file.
This function takes a struct and converts it to a JSON object using the FJsonObjectConverter::UStructToJsonObject function. It then writes the JSON contents of the converted object to a file with the given base file name without extension using the WriteJson function.
- Template Parameters
-
- Parameters
-
BaseFileNameWithoutExtension | The base file name without extension of the file to write. |
InStruct | The struct to write to the JSON file. |
- Returns
- True if the struct was successfully converted to JSON and written to the file, false otherwise.
The documentation for this class was generated from the following files: