Small refactoring before 3.2.0-boron final

This commit is contained in:
Daniele Teti 2020-06-24 00:00:47 +02:00
parent a8ac6a7206
commit a8ee598b9d
6 changed files with 50 additions and 9 deletions

View File

@ -1,2 +1,11 @@
appdirs==1.4.3
attrs==19.3.0
black==19.10b0
click==7.1.1
colorama==0.4.1
invoke==1.2.0
invoke==1.4.1
pathspec==0.7.0
pyinvoke==1.0.4
regex==2020.4.4
toml==0.10.0
typed-ast==1.4.1

View File

@ -67,8 +67,8 @@ object MainForm: TMainForm
AlignWithMargins = True
Left = 540
Top = 4
Width = 364
Height = 73
Width = 355
Height = 65
Align = alClient
Caption =
'At each authenticated request, the server increments the "exp" p' +
@ -77,9 +77,6 @@ object MainForm: TMainForm
'alidityWindowInSeconds seconds. It is useful to mimic the classi' +
'c session cookie with the semplicity of the JWT.'
WordWrap = True
ExplicitLeft = 417
ExplicitWidth = 298
ExplicitHeight = 78
end
object btnGet: TButton
AlignWithMargins = True

View File

@ -41,7 +41,7 @@ implementation
uses
MVCFramework.RESTClient,
MVCFramework.Middleware.JWT,
MVCFramework.Serializer.JSONDataObjects,
MVCFramework.Commons,
MVCFramework.SystemJSONUtils,
System.NetEncoding,
JSONDataObjects;

View File

@ -609,6 +609,10 @@ procedure SplitContentMediaTypeAndCharset(const aContentType: string; var aConte
var aContentCharSet: string);
function BuildContentType(const aContentMediaType: string; const aContentCharSet: string): string;
function StrToJSONObject(const aString: String): TJsonObject;
function StrToJSONArray(const aString: String): TJsonArray;
{ changing case }
function CamelCase(const Value: string; const MakeFirstUpperToo: Boolean = False): string;
@ -640,6 +644,8 @@ type
VPassword: string; var VHandled: Boolean);
end;
implementation
uses
@ -1414,6 +1420,17 @@ begin
end;
end;
function StrToJSONObject(const aString: String): TJsonObject;
begin
Result := MVCFramework.Serializer.JSONDataObjects.StrToJSONObject(aString);
end;
function StrToJSONArray(const aString: String): TJsonArray;
begin
Result := MVCFramework.Serializer.JSONDataObjects.StrToJSONArray(aString);
end;
initialization
gLock := TObject.Create;

View File

@ -175,6 +175,7 @@ type
procedure TValueToJsonElement(const Value: TValue; const JSON: TJDOJsonObject; const KeyName: string);
function StrToJSONObject(const AValue: string): TJDOJsonObject;
function StrToJSONArray(const AValue: string): TJDOJsonArray;
procedure JsonObjectToObject(const AJsonObject: TJDOJsonObject; const AObject: TObject;
const AType: TMVCSerializationType; const AIgnoredAttributes: TMVCIgnoredList);
@ -2187,7 +2188,24 @@ begin
on E: Exception do
begin
lJSON.Free;
raise EMVCDeserializationException.Create('Invalid JSON');
raise EMVCDeserializationException.Create('Invalid JSON Object');
end;
end;
end;
function StrToJSONArray(const AValue: string): TJDOJsonArray;
var
lJSON: TJDOJsonArray;
begin
lJSON := nil;
try
lJSON := TJDOJsonObject.Parse(AValue) as TJDOJsonArray;
Result := lJSON;
except
on E: Exception do
begin
lJSON.Free;
raise EMVCDeserializationException.Create('Invalid JSON Array');
end;
end;
end;

View File

@ -1,2 +1,2 @@
const
DMVCFRAMEWORK_VERSION = '3.2.0 (boron) RC8';
DMVCFRAMEWORK_VERSION = '3.2.0 (boron)';