mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 07:45:54 +01:00
New helper method: ObjectToJSONObjectStr to easily convert an object to a json string
This commit is contained in:
parent
8727e3a6b1
commit
179a50dcda
@ -28,6 +28,7 @@ implementation
|
||||
uses
|
||||
WineCellarAppControllerU,
|
||||
MVCFramework.Middleware.StaticFiles,
|
||||
MVCFramework.Middleware.CORS,
|
||||
System.IOUtils;
|
||||
|
||||
{$R *.dfm}
|
||||
@ -40,6 +41,7 @@ begin
|
||||
// Conf.Value[tmvcconfigkey.PathPrefix] := '/dmvc';
|
||||
end);
|
||||
MVCEngine.AddController(TWineCellarApp);
|
||||
MVCEngine.AddMiddleware(TMVCCORSMiddleware.Create);
|
||||
if not IsLibrary then
|
||||
begin
|
||||
MVCEngine.AddMiddleware(TMVCStaticFilesMiddleware.Create('/app', { StaticFilesPath }
|
||||
|
@ -673,6 +673,7 @@ function BuildContentType(const aContentMediaType: string; const aContentCharSet
|
||||
function StrToJSONObject(const aString: String; ARaiseExceptionOnError: Boolean = False): TJsonObject;
|
||||
function StrToJSONArray(const aString: String; ARaiseExceptionOnError: Boolean = False): TJsonArray;
|
||||
function ObjectToJSONObject(const aObject: TObject): TJSONObject;
|
||||
function ObjectToJSONObjectStr(const aObject: TObject): String;
|
||||
|
||||
function WrapAsList(const AObject: TObject; AOwnsObject: Boolean = False): IMVCList;
|
||||
|
||||
@ -1788,6 +1789,18 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function ObjectToJSONObjectStr(const aObject: TObject): String;
|
||||
var
|
||||
lJSON: TJsonObject;
|
||||
begin
|
||||
lJSON := ObjectToJSONObject(aObject);;
|
||||
try
|
||||
Result := lJSON.ToJSON(True);
|
||||
finally
|
||||
lJSON.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function StrToJSONObject(const aString: String; ARaiseExceptionOnError: Boolean = False): TJsonObject;
|
||||
begin
|
||||
Result := MVCFramework.Utils.StrToJSONObject(aString, ARaiseExceptionOnError);
|
||||
|
Loading…
Reference in New Issue
Block a user