public Note(Integer id, JsonValue value) { super(id, value); packable = false; index = value.has("index") ? value.getLong("index") : 0; spellcard = value.has("spellcard") ? value.getInt("spellcard") : null; }
protected static GjScoreboardEntry fromJson(JsonValue json, int rank, String currentPlayer) { GjScoreboardEntry gje = new GjScoreboardEntry(); gje.rank = String.valueOf(rank); gje.score = json.getString("score"); gje.sort = json.getLong("sort"); gje.tag = json.getString("extra_data"); String userId = json.getString("user_id"); if (userId != null && !userId.isEmpty()) { gje.userId = userId; gje.displayName = json.getString("user"); gje.currentPlayer = (currentPlayer != null && currentPlayer.equalsIgnoreCase(gje.displayName)); } else gje.displayName = json.getString("guest"); gje.stored = json.getString("stored"); return gje; }
private void parseBasics(Meta meta, JsonValue jsonRoot) { meta.setVersion(jsonRoot.getInt(Meta.JSON_VERSION)); meta.setLastModified(jsonRoot.getLong(Meta.JSON_LAST_MOD)); meta.setUuid(jsonRoot.getString(Meta.JSON_UUID)); meta.setType(AssetType.valueOf(jsonRoot.getString(Meta.JSON_TYPE))); }
@Override public void handleHttpResponse(Net.HttpResponse httpResponse) { JsonValue response = null; String json = httpResponse.getResultAsString(); // looks like a CORS error when fetching :-( try { response = new JsonReader().parse(json).get(0); int rank = 0; Array<ILeaderBoardEntry> le = new Array<ILeaderBoardEntry>(); for (JsonValue statEntry = response.child; statEntry != null && rank < limit; statEntry = statEntry.next) { rank++; KongStatEntry kse = new KongStatEntry(); kse.username = statEntry.getString("username"); kse.currentPlayer = kse.username.equalsIgnoreCase(getPlayerDisplayName()); kse.avatarUrl = statEntry.getString("avatar_url"); kse.score = statEntry.getLong("score"); kse.rank = Integer.toString(rank); le.add(kse); } callback.onLeaderBoardResponse(le); } catch (Throwable t) { Gdx.app.error(GAMESERVICE_ID, "Error querying stats " + json, t); callback.onLeaderBoardResponse(null); } }
long bytes = dataset.getLong("size"); size = GlobalResources.humanReadableByteCount(bytes, true); } catch (IllegalArgumentException e) {
try { JsonValue response = new JsonReader().parse(resultAsString); long serverTimestamp = response.getLong("server_ts") * 1000L; timeStampDiscrepancy = serverTimestamp - TimeUtils.millis(); Gdx.app.log(TAG, "Session open. Time stamp discrepancy in ms: " +