-
Notifications
You must be signed in to change notification settings - Fork 38
How to change property name when serializing UObject with Json(Version 1.5.0 or later)
Ayuma Kaminosono edited this page Jan 16, 2020
·
1 revision
You can change the property name when UObject is serialized to Json by the following procedure.
The following is an example of serializing UObject (CustomObject1) in the image.
Usually, the property name of UObject (Prop2, ObjProp, ObjProp2) becomes the property name of Json as it is as follows.
{
"Prop2": 1,
"ObjProp":
{
"ValueB": 0,
"ValueA": 0
},
"ObjProp2":
{
"ValueC": "abc"
}
}
To change the property name of Json, implement the IODConvertPropertyName
interface on the UObject (CustomObject1) to be serialized.
Implement the ConvertUPropertyName method as follows: You can assign any Json property name to the UObject property name.
If you return an empty string, the property name of UObject will be used as is.
When the above example is applied, the following Json is output.
{
"IntProperty": 1,
"ObjectPropertyA":
{
"ValueB": 0,
"ValueA": 0
},
"ObjectPropertyB":
{
"ValueC": "abc"
}
}