浏览代码

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
   Description : Utils for working with JSON
   Author      : Kike Pérez
-  Version     : 1.0
+  Version     : 1.1
   Created     : 27/01/2017
-  Modified    : 28/10/2017
+  Modified    : 13/02/2018
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
@@ -55,6 +55,9 @@ type
 
   //only public properties will be cloned or gotten
 
+  function IncludeJsonBraces(const json : string) : string;
+  function RemoveJsonBraces(const json : string) : string;
+
 
 implementation
 
@@ -103,6 +106,17 @@ begin
   cObj.FromJson(Self.ToJson);
 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.