You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
788 B
29 lines
788 B
3 years ago
|
package com.fr.plugin;
|
||
|
|
||
|
import com.fr.third.fasterxml.jackson.core.JsonGenerationException;
|
||
|
import com.fr.third.fasterxml.jackson.databind.JsonMappingException;
|
||
|
import com.fr.third.fasterxml.jackson.databind.ObjectMapper;
|
||
|
|
||
|
import java.io.IOException;
|
||
|
import java.io.StringWriter;
|
||
|
import java.io.Writer;
|
||
|
|
||
|
/**
|
||
|
* JSON序列化和反序列化相关操作类
|
||
|
*/
|
||
|
public class JSONUtils {
|
||
|
private static ObjectMapper objectMapper = new ObjectMapper();
|
||
|
|
||
|
public static String serialize(Object object) {
|
||
|
Writer write = new StringWriter();
|
||
|
try {
|
||
|
objectMapper.writeValue(write, object);
|
||
|
} catch (JsonGenerationException e) {
|
||
|
} catch (JsonMappingException e) {
|
||
|
} catch (IOException e) {
|
||
|
}
|
||
|
return write.toString();
|
||
|
}
|
||
|
|
||
|
}
|