diff --git a/samples/50.teams-messaging-extensions-search/pom.xml b/samples/50.teams-messaging-extensions-search/pom.xml
index 49ef3cfc..272e754d 100644
--- a/samples/50.teams-messaging-extensions-search/pom.xml
+++ b/samples/50.teams-messaging-extensions-search/pom.xml
@@ -72,12 +72,7 @@
log4j-api
2.11.0
-
- org.json
- json
- 20201115
-
-
+
org.apache.logging.log4j
log4j-core
2.11.0
diff --git a/samples/50.teams-messaging-extensions-search/src/main/java/com/microsoft/bot/sample/teamssearch/TeamsMessagingExtensionsSearchBot.java b/samples/50.teams-messaging-extensions-search/src/main/java/com/microsoft/bot/sample/teamssearch/TeamsMessagingExtensionsSearchBot.java
index 3d489f3a..475bd337 100644
--- a/samples/50.teams-messaging-extensions-search/src/main/java/com/microsoft/bot/sample/teamssearch/TeamsMessagingExtensionsSearchBot.java
+++ b/samples/50.teams-messaging-extensions-search/src/main/java/com/microsoft/bot/sample/teamssearch/TeamsMessagingExtensionsSearchBot.java
@@ -3,6 +3,9 @@
package com.microsoft.bot.sample.teamssearch;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import com.microsoft.bot.builder.TurnContext;
import com.microsoft.bot.builder.teams.TeamsActivityHandler;
import com.microsoft.bot.schema.*;
@@ -12,8 +15,6 @@ import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.commons.lang3.StringUtils;
-import org.json.JSONArray;
-import org.json.JSONObject;
import org.slf4j.LoggerFactory;
import java.io.IOException;
@@ -44,11 +45,14 @@ public class TeamsMessagingExtensionsSearchBot extends TeamsActivityHandler {
.thenApply(packages -> {
List attachments = new ArrayList<>();
for (String[] item : packages) {
+ ObjectNode data = Serialization.createObjectNode();
+ data.set("data", Serialization.objectToTree(item));
+
ThumbnailCard previewCard = new ThumbnailCard() {{
setTitle(item[0]);
setTap(new CardAction() {{
setType(ActionTypes.INVOKE);
- setValue(new JSONObject().put("data", item).toString());
+ setValue(Serialization.toStringSilent(data));
}});
}};
@@ -129,23 +133,22 @@ public class TeamsMessagingExtensionsSearchBot extends TeamsActivityHandler {
))
.build();
- List filteredItems = new ArrayList();
+ List filteredItems = new ArrayList<>();
try {
Response response = client.newCall(request).execute();
- JSONObject obj = new JSONObject(response.body().string());
- JSONArray dataArray = (JSONArray) obj.get("data");
+ JsonNode obj = Serialization.jsonToTree(response.body().string());
+ ArrayNode dataArray = (ArrayNode) obj.get("data");
- dataArray.forEach(i -> {
- JSONObject item = (JSONObject) i;
- filteredItems.add(new String[]{
- item.getString("id"),
- item.getString("version"),
- item.getString("description"),
- item.has("projectUrl") ? item.getString("projectUrl") : "",
- item.has("iconUrl") ? item.getString("iconUrl") : ""
+ for (int i = 0; i < dataArray.size(); i++) {
+ JsonNode item = dataArray.get(i);
+ filteredItems.add(new String[] {
+ item.get("id").asText(),
+ item.get("version").asText(),
+ item.get("description").asText(),
+ item.has("projectUrl") ? item.get("projectUrl").asText() : "",
+ item.has("iconUrl") ? item.get("iconUrl").asText() : ""
});
- });
-
+ }
} catch (IOException e) {
LoggerFactory.getLogger(TeamsMessagingExtensionsSearchBot.class)
.error("findPackages", e);