本文整理汇总了Java中org.apache.commons.lang3.StringEscapeUtils.unescapeJson方法的典型用法代码示例。如果您正苦于以下问题:Java StringEscapeUtils.unescapeJson方法的具体用法?Java StringEscapeUtils.unescapeJson怎么用?Java StringEscapeUtils.unescapeJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringEscapeUtils
的用法示例。
在下文中一共展示了StringEscapeUtils.unescapeJson方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
@Override
public void process(JSONObject content, JSONObject rawRequest, Server server) {
try {
String id = content.getString("channel_id");
String authorId = content.getJSONObject("author").getString("id");
Group group = api.getGroupById(id);
User user = api.getUserById(authorId);
group = (group == null) ? api.getGroupById(authorId) : group;
user = (user == null) ? api.getBlankUser() : user;
String msgContent = StringEscapeUtils.unescapeJson(content.getString("content"));
String msgId = content.getString("id");
String webhookId = content.has("webhook_id") ? !content.isNull("webhook_id") ? content.getString("webhook_id") : null : null;
if (webhookId != null && content.has("author")) {
JSONObject author = content.getJSONObject("author");
user = new UserImpl(author.getString("username"), webhookId, webhookId, api);
((UserImpl) user).setAvatar(author.getString("avatar"));
}
MessageImpl msg = new MessageImpl(msgContent, msgId, id, webhookId, api);
msg.setSender(user);
if (content.has("embed"))
msg.addEmbed(new Embed(content.getJSONObject("embed")));
if (content.has("embeds")) {
for (Object obj : content.getJSONArray("embeds"))
msg.addEmbed(new Embed((JSONObject) obj));
}
if (!content.isNull("edited_timestamp"))
msg.setEdited(true);
GroupUser gUser = (group.getServer() == null || webhookId != null) ? new GroupUser(user, "User", user.getId()) : group
.getServer().getGroupUserById(authorId);
api.getEventManager().executeEvent(new UserChatEvent(group, gUser, msg));
} catch (Exception e) {
api.log("Failed to process message:\n >" + content);
}
}
示例2: unescapeJson
import org.apache.commons.lang3.StringEscapeUtils; //导入方法依赖的package包/类
public String unescapeJson(String json) {
return StringEscapeUtils.unescapeJson(json);
}