@@ -2694,59 +2694,68 @@ procedure TMVCJsonDataObjectsSerializer.ObjectToJsonObject(const AObject: TObjec
26942694 InternalObjectToJsonObject(AObject, AJSONObject, AType, AIgnoredAttributes, nil , nil , nil );
26952695end ;
26962696
2697- procedure TMVCJsonDataObjectsSerializer.InternalObjectToJsonObject (
2698- const AObject: TObject;
2699- const AJSONObject: TJDOJsonObject;
2700- const AType: TMVCSerializationType;
2701- const AIgnoredAttributes: TMVCIgnoredList;
2702- const ASerializationAction: TMVCSerializationAction;
2703- const Links: IMVCLinks;
2704- const Serializer: IMVCTypeSerializer);
2697+ procedure TMVCJsonDataObjectsSerializer.InternalObjectToJsonObject (const AObject: TObject; const AJSONObject: TJDOJsonObject; const AType: TMVCSerializationType; const AIgnoredAttributes: TMVCIgnoredList; const ASerializationAction: TMVCSerializationAction; const Links: IMVCLinks; const Serializer: IMVCTypeSerializer);
27052698var
2706- ObjType: TRttiType;
2707- Prop: TRttiProperty;
2708- Fld: TRttiField;
2699+ LRttiType: TRttiType;
2700+ LRttiProperty: TRttiProperty;
2701+ LRttiField: TRttiField;
2702+ LFieldName: string;
2703+ LQualifiedFieldName: string;
27092704begin
27102705 { TODO -oDanieleT -cGeneral : Find a way to automatically add HATEOS }
27112706 if AObject = nil then
27122707 begin
27132708 Exit;
27142709 end ;
2715- ObjType := GetRttiContext.GetType(AObject.ClassType);
2710+ LRttiType := GetRttiContext.GetType(AObject.ClassType);
27162711 case AType of
27172712 stDefault, stProperties:
27182713 begin
2719- for Prop in ObjType .GetProperties do
2714+ for LRttiProperty in LRttiType .GetProperties do
27202715 begin
2721- if TMVCSerializerHelper.IsAPropertyToSkip(Prop .Name ) then
2716+ if TMVCSerializerHelper.IsAPropertyToSkip(LRttiProperty .Name ) then
27222717 begin
27232718 Continue;
27242719 end ;
2725-
2726- // if Prop.Name = 'RefCount' then
2727- // begin
2728- // Continue;
2729- // end;
2730-
2731- { $IFDEF AUTOREFCOUNT}
2732- if TMVCSerializerHelper.IsAPropertyToSkip(Prop.Name ) then
2720+ { $IFDEF AUTOREFCOUNT}
2721+ if TMVCSerializerHelper.IsAPropertyToSkip(LRttiProperty.Name ) then
27332722 continue;
2734-
2735- { $ENDIF}
2736- if (not TMVCSerializerHelper.HasAttribute<MVCDoNotSerializeAttribute>(Prop)) and
2737- (not IsIgnoredAttribute(AIgnoredAttributes, Prop.Name )) then
2738- TValueToJSONObjectProperty(AJSONObject, TMVCSerializerHelper.GetKeyName(Prop, ObjType),
2739- Prop.GetValue(AObject), AType, AIgnoredAttributes, Prop.GetAttributes);
2723+ { $ENDIF}
2724+
2725+ LFieldName := LRttiProperty.Name ;
2726+ LQualifiedFieldName := Format(' %s.%s' , [AObject.ClassName, LRttiProperty.Name ]);
2727+ if (not TMVCSerializerHelper.HasAttribute<MVCDoNotSerializeAttribute>(LRttiProperty)) and
2728+ (not IsIgnoredAttribute(AIgnoredAttributes, LFieldName)) and
2729+ (not IsIgnoredAttribute(AIgnoredAttributes, LQualifiedFieldName))
2730+ then
2731+ TValueToJSONObjectProperty(
2732+ AJSONObject,
2733+ TMVCSerializerHelper.GetKeyName(LRttiProperty, LRttiType),
2734+ LRttiProperty.GetValue(AObject),
2735+ AType,
2736+ AIgnoredAttributes,
2737+ LRttiProperty.GetAttributes
2738+ );
27402739 end ;
27412740 end ;
27422741 stFields:
27432742 begin
2744- for Fld in ObjType .GetFields do
2743+ for LRttiField in LRttiType .GetFields do
27452744 begin
2746- if (not TMVCSerializerHelper.HasAttribute<MVCDoNotSerializeAttribute>(Fld)) and
2747- (not IsIgnoredAttribute(AIgnoredAttributes, Fld.Name )) then
2748- TValueToJSONObjectProperty(AJSONObject, TMVCSerializerHelper.GetKeyName(Fld, ObjType),
2749- Fld.GetValue(AObject), AType, AIgnoredAttributes, Fld.GetAttributes);
2745+ LFieldName := LRttiField.Name ;
2746+ LQualifiedFieldName := Format(' %s.%s' , [AObject.ClassName, LRttiField.Name ]);
2747+ if (not TMVCSerializerHelper.HasAttribute<MVCDoNotSerializeAttribute>(LRttiField)) and
2748+ (not IsIgnoredAttribute(AIgnoredAttributes, LFieldName)) and
2749+ (not IsIgnoredAttribute(AIgnoredAttributes, LQualifiedFieldName))
2750+ then
2751+ TValueToJSONObjectProperty(
2752+ AJSONObject,
2753+ TMVCSerializerHelper.GetKeyName(LRttiField, LRttiType),
2754+ LRttiField.GetValue(AObject),
2755+ AType,
2756+ AIgnoredAttributes,
2757+ LRttiField.GetAttributes
2758+ );
27502759 end ;
27512760 end ;
27522761 end ;
0 commit comments