Announcement

Collapse
No announcement yet.

Need help about FJsonObjectConverter::UStructToJsonObject ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need help about FJsonObjectConverter::UStructToJsonObject ?

    Hello Everyone,

    This is my first post here


    I encounter a problem in my code today, I create a map editor for my Puzzle Reflexion Game which saves my levels into a json file.
    However, I really don't unterstand how to use this function... :

    https://docs.unrealengine.com/en-US/...t/2/index.html

    HTML Code:
    for (auto it = JsonArray.CreateIterator(); it; ++it)
            {
                int32 index = it.GetIndex();
                TSharedPtr<FJsonValue> value = JsonArray[index];
                TSharedPtr<FJsonObject> json = value->AsObject();
                if (Level.Name == json->GetStringField("Name")) {
                    exist = true;
                    TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
                    if (!FJsonObjectConverter::UStructToJsonObject(??, &Level, JsonObject.ToSharedRef(), 0, 0)) {
                        ret = false;
                    }
                    json = JsonObject;
    
                    FString OutputString;
                    TSharedRef< TJsonWriter<> > Writer = TJsonWriterFactory<>::Create(&OutputString);
                    FJsonSerializer::Serialize(JsonArray, Writer);
                    ret = FFileHelper::SaveStringToFile(OutputString, *path2);
                    break;
                }
            }
    To explain this loop, I try to replace a stored save in my json.
    Level is an instanciated custom struct, called FLevelStruct, which contains all my levels informations.

    I don't know how I can get an UStruct* from my FLevelStruct..

    I hope I can find help here.

    In advance, thanks you !

    Jason
    Last edited by Jay974; 03-29-2020, 01:41 PM.

    #2
    I think you could use FLevelStruct::StaticClass().

    Comment

    Working...
    X