diff --git a/requirements.txt b/requirements.txt index efd939ce..5dd35658 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/samples/jsonwebtoken_livevaliditywindow/vclclient/MainClientFormU.dfm b/samples/jsonwebtoken_livevaliditywindow/vclclient/MainClientFormU.dfm index 3361eb4f..2cd2ebb0 100644 --- a/samples/jsonwebtoken_livevaliditywindow/vclclient/MainClientFormU.dfm +++ b/samples/jsonwebtoken_livevaliditywindow/vclclient/MainClientFormU.dfm @@ -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 diff --git a/samples/jsonwebtoken_livevaliditywindow/vclclient/MainClientFormU.pas b/samples/jsonwebtoken_livevaliditywindow/vclclient/MainClientFormU.pas index f55af52e..7a7710d1 100644 --- a/samples/jsonwebtoken_livevaliditywindow/vclclient/MainClientFormU.pas +++ b/samples/jsonwebtoken_livevaliditywindow/vclclient/MainClientFormU.pas @@ -41,7 +41,7 @@ implementation uses MVCFramework.RESTClient, MVCFramework.Middleware.JWT, - MVCFramework.Serializer.JSONDataObjects, + MVCFramework.Commons, MVCFramework.SystemJSONUtils, System.NetEncoding, JSONDataObjects; diff --git a/sources/MVCFramework.Commons.pas b/sources/MVCFramework.Commons.pas index 1c97f8ed..d89830d4 100644 --- a/sources/MVCFramework.Commons.pas +++ b/sources/MVCFramework.Commons.pas @@ -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; diff --git a/sources/MVCFramework.Serializer.JsonDataObjects.pas b/sources/MVCFramework.Serializer.JsonDataObjects.pas index 8140b62a..b71b3d66 100644 --- a/sources/MVCFramework.Serializer.JsonDataObjects.pas +++ b/sources/MVCFramework.Serializer.JsonDataObjects.pas @@ -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; diff --git a/sources/dmvcframeworkbuildconsts.inc b/sources/dmvcframeworkbuildconsts.inc index c85cd899..38070b2a 100644 --- a/sources/dmvcframeworkbuildconsts.inc +++ b/sources/dmvcframeworkbuildconsts.inc @@ -1,2 +1,2 @@ const - DMVCFRAMEWORK_VERSION = '3.2.0 (boron) RC8'; \ No newline at end of file + DMVCFRAMEWORK_VERSION = '3.2.0 (boron)'; \ No newline at end of file