本文整理匯總了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);
}