Page MenuHomeFeedback Tracker

SCR_JsonLoadContext::ReadValue aborting on properties not present in the json data
Closed, ResolvedPublic

Description

After today's stable update, when the JSON data contains fewer fields than the target class to read to it seems to just abort. it should ignore those fields and continue to match further class properties.
This currently renders my entire persistence framework and game modes built on top unusable. An urgent hotfix is required!

class EDF_DbEntityUtils
{
	//------------------------------------------------------------------------------------------------
	static bool StructAutoCopy(notnull Managed from, notnull Class to)
	{
		SCR_JsonSaveContext writer();
		if (!writer.WriteValue("", from))
			return false;

		string data = writer.ExportToString();

		SCR_JsonLoadContext reader();
		if (!reader.ImportFromString(data))
			return false;

		return reader.ReadValue("", to);
	}
};

class TypeA
{
	int someProp;
}

class TypeB
{
	int someOtherProp; // This causes the problem
	int someProp;
}

void Test()
{
    TypeA a();
    a.someProp = 1337;

    TypeB b();
    Print(EDF_DbEntityUtils.StructAutoCopy(a, b));
}

The resulting print is 0/false and the b instance only has default values.

Details

Severity
Block
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General

Event Timeline

Arkensor created this task.Jul 20 2023, 7:58 PM
Geez closed this task as Resolved.Jul 21 2023, 10:25 AM
Geez claimed this task.
Geez added a subscriber: Geez.

Hello Arkensor.
The issue has been fixed internally and the fix will appear in one of the future updates.