Java对象转Json字符串 本方法转换后字符串可以兼容各浏览器 @param object Java对象,可以是对象,数组,List,Map等 @return json 字符串
(Object object)
| 48 | * @return json 字符串 |
| 49 | */ |
| 50 | public String toJSONString(Object object) { |
| 51 | String jsonString = ""; |
| 52 | try { |
| 53 | |
| 54 | jsonString = objectMapper.writeValueAsString(object); |
| 55 | |
| 56 | } catch (Exception e) { |
| 57 | //e.printStackTrace(); |
| 58 | if (logger.isErrorEnabled()) { |
| 59 | logger.error("Java对象转Json字符串",e); |
| 60 | } |
| 61 | } |
| 62 | return jsonString; |
| 63 | |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Json字符串转Java对象 |
no outgoing calls
no test coverage detected