Skip to content

Selection of Json serialize method in ObjectDeliveryBoxUsingJson(Version 1.5.0 later)

Ayuma Kaminosono edited this page Jan 22, 2020 · 3 revisions

In Version 1.5.0 or later, the Json serialization format of UObject can be selected from the following two types.

  • Do not include the class name (conventional format)
{
    "Prop": 1
}
  • Include class name
{
    "Type": "SampleClassName",
    "Body":
    {
        "Prop": 1
    }
}

By including the class name in json, multiple types can be serialized and deserialized in one DeliveryBox. Even if you have an object as a property of the type of the base class, the information will not be lost.

But the class name is saved for each object, so the number of characters (data size) of json increases.

Select serialization method

I will explain in the case of serialization of the blueprint below

ODConvertPropertyName3

  • The class name of this blueprint is CustomObject1
  • Has a property named Prop2 for Integer
  • Has a property named ObjProp of type CustomObjA
  • ObjProp contains an instance of CustomObjB
  • CustomObjB inherits from CustomObjA
  • Has a property named ObjProp2 of type CustomObjC

ObjA ObjB ObjC

Do not include the class name (conventional format)

Create a Delivery Box using Create Object Delivery Box Using Json.

boxStatic

Serialized to the following json text

{
    "Prop2": 1,
    "ObjProp":
    {
        "ValueB": 2,
        "ValueA": 3
    },
    "ObjProp2":
    {
        "ValueC": "abc"
    }
}
  • Class names are not saved
  • When deserializing, it is necessary to specify the target class (CustomObject1)
  • ObjProp is restored as CustomObjA type, so ValueB implemented in CustomObjB is not restored

Include class name

Create a Delivery Box using Create Dynamic Object Delivery Box Using Json.

boxDynamic

Serialized to the following json text

{
    "Type": "CustomObject1_C",
    "Body":
    {
        "Prop2": 1,
        "ObjProp":
        {
            "Type": "CustomObjB_C",
            "Body":
            {
                "ValueB": 2,
                "ValueA": 3
            }
        },
        "ObjProp2":
        {
            "Type": "CustomObjC_C",
            "Body":
            {
                "ValueC": "abc"
            }
        }
    }
}
  • Class names are saved
  • No need to specify target class (CustomObject1) when deserializing
  • ObjProp is restored as "CustomObjB" type, so ValueB implemented in "CustomObjB" is also restored

Custom format (switch for each class)

Create a Delivery Box using Create Custom Object Delivery Box Using Json.

image

Serialized to the following json text(For the above image settings)

{
    "Prop2": 1,
    "ObjProp":
    {
        "Type": "CustomObjB_C",
        "Body":
        {
            "ValueB": 2,
            "ValueA": 3
        }
    },
    "ObjProp2":
    {
        "ValueC": "abc"
    }
}
  • Set the default serialization method type to Default Serializer Type
  • If you specify No Write Type in Default Serializer Type, you must always specify Target Class.
  • Set the object class and serialization method type of the property as a pair in Object Serializer Types