Today I share a more practical library
Can easily realize the conversion of Object and String
Convenient log debugging, and special development scenarios
For example, you need to pass a special String object in the past
Can be converted like this
The method of use is also very simple, first import the following library
compile 'com.alibaba:fastjson:1.2.47'
Then there is the specific method
I wrote a tool class here, which can be used directly
public class AlibabaUtil {
/**
* 对象转换成String
* @param object
* @return
*/
public static String ObjectToString(Object object) {
return com.alibaba.fastjson.JSONObject.toJSONString(object);
}
/**
* String转换成对象
* @param string
* @return
*/
public static Object StringToObject(String string) {
return com.alibaba.fastjson.JSONObject.parse(string);
}
}