Browse Source

添加json对象为null返回空字符串方法

DuGuYang 1 year ago
parent
commit
ac8242cdea

File diff suppressed because it is too large
+ 0 - 0
Areas/Api/Controllers/Main/MerchantAddInfoController.cs


+ 22 - 0
Util/Extension/JsonDataExtension.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using LitJson;
+
+namespace MySystem
+{
+    public static class JsonDataExtension
+    {
+        
+        #region 获取是否存在Key, isFlag判断是抛出异常还是返回""
+        public static object getItem(this JsonData input, string key) 
+        {
+            string jsonString = input.ToJson();
+            if(jsonString.Contains("\"" + key + "\""))
+            {
+                return input[key];
+            }
+            return "";
+        }
+        #endregion
+    }
+}

+ 17 - 0
Util/Extension/StringExtension.cs

@@ -0,0 +1,17 @@
+
+namespace MySystem
+{
+    public static class StringExtension
+    {
+        #region sql条件拼装
+        public static string Like(this string input, string Field, string Value) 
+        {
+            if (!string.IsNullOrEmpty(Value))
+            {
+                input += " and " + Field + " like '%" + Value + "%'";
+            }
+            return input;
+        }
+        #endregion
+    }
+}

Some files were not shown because too many files changed in this diff