If you try to read an array as the first property of a child object in JSON it fails. Putting any other primitive value before that makes the array read afterward work. I suspect some read mode is not set up until a normal non-collection value is read from the section.
class MyTestObject { protected bool SerializationSave(BaseSerializationSaveContext saveContext) { saveContext.WriteValue("dataLayoutVersion", 1); saveContext.WriteValue("id", "5A0CD41A-0000-0001-0000-00004ED19D80"); saveContext.WriteValue("prefab", "F649585ABB3706C4"); saveContext.StartObject("components"); //saveContext.WriteValue("somestring", "hello world"); array<string> componentTypesInOrder = {"Transformation", "HitZoneContainer", "FuelManager"}; saveContext.WriteValue("order", componentTypesInOrder); saveContext.EndObject(); return true; } protected bool SerializationLoad(BaseSerializationLoadContext loadContext) { int dataLayoutVersion; Print("Read_dataLayoutVersion: " + loadContext.ReadValue("dataLayoutVersion", dataLayoutVersion)); Print(dataLayoutVersion); string id; Print("Read_id: " + loadContext.ReadValue("id", id)); Print(id); string prefab; Print("Read_id: " + loadContext.ReadValue("prefab", prefab)); Print(prefab); loadContext.StartObject("components"); //string somestring; //Print("somestring_id: " + loadContext.ReadValue("somestring", somestring)); //Print(somestring); array<string> componentTypesInOrder(); Print("order_Read: " + loadContext.ReadValue("order", componentTypesInOrder)); Print(componentTypesInOrder); loadContext.EndObject(); return true; } }
MyTestObject input(); SCR_JsonSaveContext writer(); writer.WriteValue("entity", input); string dataString = writer.ExportToString(); Print(dataString); MyTestObject output(); SCR_JsonLoadContext reader(); reader.ImportFromString(dataString); reader.ReadValue("entity", output);
SCRIPT : string dataString = '{"entity":{"dataLayoutVersion":1,"id":"5A0CD41A-0000-0001-0000-00004ED19D80","prefab":"F649585ABB3706C4","components":{"order":["Transformation","HitZoneContainer","FuelManager"]}}}'
SCRIPT : Read_dataLayoutVersion: true
SCRIPT : int dataLayoutVersion = 1
SCRIPT : Read_id: true
SCRIPT : string id = '5A0CD41A-0000-0001-0000-00004ED19D80'
SCRIPT : Read_id: true
SCRIPT : string prefab = 'F649585ABB3706C4'
SCRIPT : order_Read: false
SCRIPT : array<string> componentTypesInOrder = 0x0000016F17D41A38 {}