File tree 1 file changed +2
-31
lines changed
huaweicloud-sdk-java-dis/src/main/java/com/huaweicloud/dis/util
1 file changed +2
-31
lines changed Original file line number Diff line number Diff line change 24
24
import com .fasterxml .jackson .core .JsonProcessingException ;
25
25
import com .fasterxml .jackson .core .type .TypeReference ;
26
26
import com .fasterxml .jackson .databind .ObjectMapper ;
27
+ import com .fasterxml .jackson .databind .PropertyNamingStrategies ;
27
28
import com .fasterxml .jackson .databind .PropertyNamingStrategy ;
28
29
import com .fasterxml .jackson .databind .PropertyNamingStrategy .PropertyNamingStrategyBase ;
29
30
import com .fasterxml .jackson .databind .SerializationFeature ;
@@ -43,36 +44,6 @@ public class JsonUtils
43
44
mapper .configure (SerializationFeature .FAIL_ON_EMPTY_BEANS , false ); // 遇到空Bean不报错
44
45
}
45
46
46
- /*
47
- * 自定义属性命名策略:首字母转小写
48
- */
49
- public static final PropertyNamingStrategy CASE_FIRST_WORD_TO_LOWER_CASE = new MyPropertyNameingStrategy ();
50
-
51
- /**
52
- * json转换为java对象
53
- *
54
- * @param <T>
55
- * 转换为的java对象
56
- * @param json
57
- * json字符串
58
- * @param typeReference
59
- * jackjson自定义的类型
60
- * @return 返回Java对象
61
- */
62
- public static <T > T jsonToObj (String json , TypeReference <T > typeReference )
63
- {
64
- mapper .setPropertyNamingStrategy (new DefaultPropertyNameingStrategy ());
65
- try
66
- {
67
- return mapper .readValue (json , typeReference );
68
- }
69
- catch (IOException e )
70
- {
71
- logger .error ("Fail to read value of JSON. " + e );
72
- }
73
-
74
- return null ;
75
- }
76
47
77
48
/**
78
49
* json转换为java对象
@@ -181,7 +152,7 @@ public static String objToJson(Object object, PropertyNamingStrategy pns)
181
152
}
182
153
183
154
private static class MyPropertyNameingStrategy extends
184
- PropertyNamingStrategyBase
155
+ PropertyNamingStrategies . NamingBase
185
156
{
186
157
private static final long serialVersionUID = 1L ;
187
158
You can’t perform that action at this time.
0 commit comments