From f4d8775acba7b0ed4145e270a12a2c5bff8413b8 Mon Sep 17 00:00:00 2001 From: 403f <1292451605@qq.com> Date: Sat, 10 Apr 2021 22:44:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9JSONResponse.java=E4=B8=AD=E7=9A=84for?= =?UTF-8?q?matHyphen=E6=96=B9=E6=B3=95=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/apijson/JSONResponse.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/APIJSONORM/src/main/java/apijson/JSONResponse.java b/APIJSONORM/src/main/java/apijson/JSONResponse.java index 5cc3a0b6e..ae60fd247 100755 --- a/APIJSONORM/src/main/java/apijson/JSONResponse.java +++ b/APIJSONORM/src/main/java/apijson/JSONResponse.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Set; +import java.util.StringTokenizer; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -502,23 +503,17 @@ public static String formatColon(@NotNull String key) { * @return */ public static String formatHyphen(@NotNull String key, boolean firstCase) { - boolean first = true; - int index; - String name = ""; - String part; - do { - index = key.indexOf("-"); - part = index < 0 ? key : key.substring(0, index); - - name += firstCase && first == false ? StringUtil.firstCase(part, true) : part; - key = key.substring(index + 1); - first = false; - } - while (index >= 0); + StringTokenizer parts = new StringTokenizer(key, "-"); + name += parts.nextToken(); + while(parts.hasMoreTokens()) + { + String part = parts.nextToken(); + name += firstCase ? StringUtil.firstCase(part, true) : part; + } - return name; + return name; }