-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConvertUtils.java
More file actions
37 lines (28 loc) · 1.12 KB
/
ConvertUtils.java
File metadata and controls
37 lines (28 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package converter;
public class ConvertUtils {
public static void joinPair(StringBuilder result, String key, String value) {
result.append("\"").append(key).append("\": ").append(value);
}
public static void warpWithCurlyBrace(StringBuilder result) {
result.insert(0, "{").append("}");
}
public static void wrapWithAngleBrackets(StringBuilder result) {
result.insert(0, "<").append(">");
}
public static void warpWithSuareBrace(StringBuilder result) {
result.insert(0, "[").append("]");
}
public static String removeDoubleQuotesIfExist(String value) {
return value.startsWith("\"") ? value.substring(1, value.length() - 1) : value;
}
public static String removeSpaceAndLine(String value) {
value = value.replaceAll("\\s", "").replaceAll("\r\n", "").replaceAll("\n", "");
return value;
}
public static String removeSpaceBetweenAngleBrackets(String str) {
return str.replaceAll(">\\s+<", "><");
}
public static String removeLine(String json) {
return json.replaceAll("\r\n", "").replaceAll("\n", "");
}
}