From 3c46a72672aa24f3d34227396e2d44e641a764af Mon Sep 17 00:00:00 2001 From: Yuriy Toporovskyy Date: Wed, 26 May 2021 16:48:39 -0400 Subject: [PATCH] Bug fix: handle the case where a container has only default elements --- .../Serialization/Json/BasicContainerSerializer.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Code/Framework/AzCore/AzCore/Serialization/Json/BasicContainerSerializer.cpp b/Code/Framework/AzCore/AzCore/Serialization/Json/BasicContainerSerializer.cpp index 400a3b7949..525e42a1dd 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/Json/BasicContainerSerializer.cpp +++ b/Code/Framework/AzCore/AzCore/Serialization/Json/BasicContainerSerializer.cpp @@ -102,6 +102,17 @@ namespace AZ return context.Report(retVal, "Processing of basic container was halted."); } + // If each container element was 'DefaultsUsed', then the result code will be 'DefaultsUsed' + // But this is wrong if the container has at least one element, because a container with + // at least one element is certainly not the default container value. + // Basically, the following are different objects: + // [ {} ] // The container which has only default elements, but is not the empty container + // {} // The default container, which is empty + if (index > 0) + { + retVal.Combine(JSR::ResultCode(JSR::Tasks::WriteValue, JSR::Outcomes::Success)); + } + if (context.ShouldKeepDefaults()) { outputValue = AZStd::move(array);