diff --git a/sources/MVCFramework.View.Renderers.TemplatePro.pas b/sources/MVCFramework.View.Renderers.TemplatePro.pas index 22a08e39..69ab30dd 100644 --- a/sources/MVCFramework.View.Renderers.TemplatePro.pas +++ b/sources/MVCFramework.View.Renderers.TemplatePro.pas @@ -96,7 +96,11 @@ var begin if not aValue.IsObject then begin - Result := '(Error: Cannot serialize non-object as JSON)'; + if aValue.IsType then + begin + Exit(aValue.AsInt64); + end; + Exit('(Error: Cannot serialize non-object as JSON)'); end; if TDuckTypedList.CanBeWrappedAsList(aValue.AsObject, lWrappedList) then diff --git a/sources/TemplatePro.pas b/sources/TemplatePro.pas index db6f7939..e8e8f5df 100644 --- a/sources/TemplatePro.pas +++ b/sources/TemplatePro.pas @@ -459,7 +459,11 @@ function TTProCompiledTemplate.GetDataSetFieldAsTValue(const aDataSet: TDataSet; var lField: TField; begin - lField := aDataSet.FieldByName(FieldName); + lField := aDataSet.FindField(FieldName); + if not Assigned(lField) then + begin + Exit(TValue.Empty); + end; case lField.DataType of ftInteger, ftSmallInt, ftWord: Result := lField.AsInteger;