|
@@ -0,0 +1,38 @@
|
|
|
+package com.winhc.task;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author π
|
|
|
+ * @Description:
|
|
|
+ * @date 2023/4/13 10:56
|
|
|
+ */
|
|
|
+public class Schemes {
|
|
|
+ public static void main(String[] args) {
|
|
|
+ List<String> req = Arrays.asList("scode", "holder_name", "pledgee", "sharefrozennum", "deleted");
|
|
|
+ JSONObject j = new JSONObject();
|
|
|
+ JSONObject re = new JSONObject();
|
|
|
+ j.forEach((k, v) -> {
|
|
|
+ if (null == v) {
|
|
|
+ re.fluentPut(k, new JSONObject().fluentPut("type", Arrays.asList("null", "string")));
|
|
|
+ } else if (v instanceof String) {
|
|
|
+ List<String> a = Collections.singletonList("string");
|
|
|
+ if (!req.contains(a)) {
|
|
|
+ a.add("null");
|
|
|
+ }
|
|
|
+ re.fluentPut(k, new JSONObject().fluentPut("type", Arrays.asList("null", "string")));
|
|
|
+ } else if (v instanceof Double || v instanceof Integer || v instanceof Long) {
|
|
|
+ List<String> a = Collections.singletonList("number");
|
|
|
+ if (!req.contains(a)) {
|
|
|
+ a.add("null");
|
|
|
+ }
|
|
|
+ re.fluentPut(k, new JSONObject().fluentPut("type", Arrays.asList("null", "number")));
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|