Skip to content

Commit

Permalink
Parse JSON first as map then as list to handle new nodeBB API (#10206)
Browse files Browse the repository at this point in the history
  • Loading branch information
ron-murhammer authored Mar 20, 2022
1 parent f783ac2 commit 9780197
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,14 @@ private String uploadSaveGame(
final int status = response.getStatusLine().getStatusCode();
if (status == HttpURLConnection.HTTP_OK) {
final String json = EntityUtils.toString(response.getEntity());
final String url = (String) YamlReader.readList(json).get(0).get("url");
return "\n[Savegame](" + url + ")";
try {
final String url = (String) YamlReader.readMap(json).get("url");
return "\n[Savegame](" + url + ")";
} catch (final Exception e) {
// This is a temporary hack to handle old versions of nodeBB forum json
final String url = (String) YamlReader.readList(json).get(0).get("url");
return "\n[Savegame](" + url + ")";
}
}
throw new IllegalStateException(
"Failed to upload savegame, server returned Error Code "
Expand Down

0 comments on commit 9780197

Please sign in to comment.