JsonUpgradeStep

Summary: Transform older saved JSON before reading it into the current data type.

Description

This optional helper is available when the Unity Newtonsoft JSON package is installed. The supplied action edits the saved object inside the Save System wrapper. Register a step for each version transition you need. It implements ISaveUpgradeStep.

Namespace Gley.SaveSystem.Newtonsoft.

Declaration

C#
public class JsonUpgradeStep<T> : ISaveUpgradeStep

Members

MemberTypeDescription
JsonUpgradeStepConstructorJsonUpgradeStep(int fromVersion, Action<JObject> upgrade)
Creates a step that transforms data from the specified version to the next version.
FromVersionintVersion the step accepts.
TargetTypeTypeData type T the step upgrades.
TryApply—bool TryApply(byte[] wrappedUtf8Json, out byte[] upgraded, out string error)
Applies the action to the wrapped UTF-8 JSON and reports the transformed bytes or an error.

Example

See the AddUpgradeStep example for a complete component that registers a JSON field rename.

On This Page