prettyJson use Gson , htmlEscaping

This commit is contained in:
MaxKey 2023-02-14 16:01:04 +08:00
parent 84217d5c91
commit 3ab0551f2f

View File

@ -81,6 +81,24 @@ public class JsonPretty implements Pretty{
return json;
}
/**
* prettyJson use Gson , htmlEscaping
* @param bean
* @return String
*/
public String format(Object bean,boolean htmlEscaping){
if(!htmlEscaping) {
return format(bean);
}
Gson gson = new GsonBuilder()
.setPrettyPrinting()
.disableHtmlEscaping()
.create();
String json = gson.toJson(bean);
return json;
}
/**
* prettyJson use Gson
* @param bean