소스 검색

JSONUtils new functions

Unknown 7 년 전
부모
커밋
2d6c30f9e4
1개의 변경된 파일17개의 추가작업 그리고 3개의 파일을 삭제
  1. 17 3
      Quick.JSONUtils.pas

+ 17 - 3
Quick.JSONUtils.pas

@@ -1,13 +1,13 @@
 { ***************************************************************************
 { ***************************************************************************
 
 
-  Copyright (c) 2015-2017 Kike Pérez
+  Copyright (c) 2015-2018 Kike Pérez
 
 
   Unit        : Quick.JSONUtils
   Unit        : Quick.JSONUtils
   Description : Utils for working with JSON
   Description : Utils for working with JSON
   Author      : Kike Pérez
   Author      : Kike Pérez
-  Version     : 1.0
+  Version     : 1.1
   Created     : 27/01/2017
   Created     : 27/01/2017
-  Modified    : 28/10/2017
+  Modified    : 13/02/2018
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -55,6 +55,9 @@ type
 
 
   //only public properties will be cloned or gotten
   //only public properties will be cloned or gotten
 
 
+  function IncludeJsonBraces(const json : string) : string;
+  function RemoveJsonBraces(const json : string) : string;
+
 
 
 implementation
 implementation
 
 
@@ -103,6 +106,17 @@ begin
   cObj.FromJson(Self.ToJson);
   cObj.FromJson(Self.ToJson);
 end;
 end;
 
 
+function IncludeJsonBraces(const json : string) : string;
+begin
+  if (not json.StartsWith('{')) and (not json.EndsWith('}')) then Result := '{' + json + '}'
+    else Result := json;
+end;
+
+function RemoveJsonBraces(const json : string) : string;
+begin
+  if (json.StartsWith('{')) and (json.EndsWith('}')) then Result := Copy(json,2,Json.Length - 2)
+    else Result := json;
+end;
 
 
 
 
 end.
 end.