private void importTrackIdSet() { this.trackIdSet = new HashSet<>(); String tracksUrl = conferenceBaseUrl + "/tracks"; LOGGER.debug("Sending a request to: {}", tracksUrl); JsonObject rootObject = readJson(tracksUrl, JsonReader::readObject); JsonArray tracksArray = rootObject.getJsonArray("tracks"); for (int i = 0; i < tracksArray.size(); i++) { trackIdSet.add(tracksArray.getJsonObject(i).getString("id")); } }
private void importTalkTypeList() { this.talkTypeIdToTalkTypeMap = new HashMap<>(); List<TalkType> talkTypeList = new ArrayList<>(); String proposalTypeUrl = conferenceBaseUrl + "/proposalTypes"; LOGGER.debug("Sending a request to: {}", proposalTypeUrl); JsonObject rootObject = readJson(proposalTypeUrl, JsonReader::readObject); JsonArray talkTypeArray = rootObject.getJsonArray("proposalTypes"); for (int i = 0; i < talkTypeArray.size(); i++) { JsonObject talkTypeObject = talkTypeArray.getJsonObject(i); String talkTypeId = talkTypeObject.getString("id"); if (talkTypeIdToTalkTypeMap.keySet().contains(talkTypeId)) { LOGGER.warn("Duplicate talk type in {} at index {}.", proposalTypeUrl, i); continue; } TalkType talkType = new TalkType((long) i, talkTypeId); talkType.setCompatibleRoomSet(new HashSet<>()); talkType.setCompatibleTimeslotSet(new HashSet<>()); talkTypeList.add(talkType); talkTypeIdToTalkTypeMap.put(talkTypeId, talkType); } solution.setTalkTypeList(talkTypeList); }
String speakerUrl = speakerArray.getJsonObject(i).getJsonArray("links").getJsonObject(0).getString("href"); LOGGER.debug("Sending a request to: {}", speakerUrl); JsonObject speakerObject = readJson(speakerUrl, JsonReader::readObject);
JsonArray daysArray = readJson(schedulesUrl, JsonReader::readObject).getJsonArray("links"); for (int i = 0; i < daysArray.size(); i++) { JsonObject dayObject = daysArray.getJsonObject(i); String dayUrl = dayObject.getString("href"); JsonObject timeslotObject = daySlotsArray.getJsonObject(j);
private void importRoomList() { this.roomIdToRoomMap = new HashMap<>(); List<Room> roomList = new ArrayList<>(); String roomsUrl = conferenceBaseUrl + "/rooms/"; LOGGER.debug("Sending a request to: {}", roomsUrl); JsonObject rootObject = readJson(roomsUrl, JsonReader::readObject); JsonArray roomArray = rootObject.getJsonArray("rooms"); for (int i = 0; i < roomArray.size(); i++) { JsonObject roomObject = roomArray.getJsonObject(i); String id = roomObject.getString("id"); int capacity = roomObject.getInt("capacity"); if (!Arrays.asList(IGNORED_ROOM_IDS).contains(id)) { Room room = new Room((long) i); room.setName(id); room.setCapacity(capacity); room.setTalkTypeSet(getTalkTypeSetForCapacity(capacity)); for (TalkType talkType : room.getTalkTypeSet()) { talkType.getCompatibleRoomSet().add(room); } room.setTagSet(new HashSet<>()); room.setUnavailableTimeslotSet(new HashSet<>()); roomList.add(room); roomIdToRoomMap.put(id, room); } } roomList.sort(Comparator.comparing(Room::getName)); solution.setRoomList(roomList); }
JsonObject groupJson = groups.getJsonObject(i); String groupName = groupJson.getString("display"); String groupId = groupJson.getString("value");
JsonObject jwk = jwks.getJsonObject(i); String kid = jwk.getString("kid", null); String kty = jwk.getString("kty", null);
private void importTalkList() { this.talkCodeToTalkMap = new HashMap<>(); solution.setTalkList(new ArrayList<>()); String talksUrl = conferenceBaseUrl + "/talks"; LOGGER.debug("Sending a request to: {}", talksUrl); JsonArray talkArray = readJson(talksUrl, JsonReader::readObject).getJsonObject("talks").getJsonArray("accepted"); for (int i = 0; i < talkArray.size(); i++) { JsonObject talkObject = talkArray.getJsonObject(i); String code = talkObject.getString("id"); String title = talkObject.getString("title"); String talkTypeId = talkObject.getJsonObject("talkType").getString("id"); Set<String> themeTrackSet = extractThemeTrackSet(talkObject, code, title); String language = talkObject.getString("lang"); int audienceLevel = Integer.parseInt(talkObject.getString("audienceLevel").replaceAll("[^0-9]", "")); List<Speaker> speakerList = extractSpeakerList(talkObject, code, title); Set<String> contentTagSet = extractContentTagSet(talkObject); if (!Arrays.asList(IGNORED_TALK_TYPES).contains(talkTypeId)) { createTalk(code, title, talkTypeId, themeTrackSet, language, speakerList, audienceLevel, contentTagSet); } } }
JsonObject entry = array.getJsonObject(i);
@Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { FullHttpRequest request = (FullHttpRequest) msg; JsonArray result = Json.createReader(new StringReader(request.content().toString(StandardCharsets.UTF_8))) .readArray(); List<Position> positions = new LinkedList<>(); for (int i = 0; i < result.size(); i++) { JsonObject message = result.getJsonObject(i); JsonString ident = message.getJsonString("ident"); if (ident == null) { continue; } DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, ident.getString()); if (deviceSession == null) { continue; } Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); decodePosition(message, position); positions.add(position); } sendResponse(channel, HttpResponseStatus.OK); return positions; }
sb.append(array.getString(x)); } else { final JsonObject lo = array.getJsonObject(x); if (lo.containsKey("type") && !lo.isNull("type") && lo.containsKey("url") && !lo.isNull("url")) {
JsonArray result = json.getJsonArray("results"); if (result != null) { JsonArray locations = result.getJsonObject(0).getJsonArray("locations"); if (locations != null) { JsonObject location = locations.getJsonObject(0);
/** * Returns an array of RoleInfo corresponding to the JSON serialization returned * by {@link AddressControl#getRolesAsJSON()}. */ public static RoleInfo[] from(final String jsonString) throws Exception { JsonArray array = JsonUtil.readJsonArray(jsonString); RoleInfo[] roles = new RoleInfo[array.size()]; for (int i = 0; i < array.size(); i++) { JsonObject r = array.getJsonObject(i); RoleInfo role = new RoleInfo(r.getString("name"), r.getBoolean("send"), r.getBoolean("consume"), r.getBoolean("createDurableQueue"), r.getBoolean("deleteDurableQueue"), r.getBoolean("createNonDurableQueue"), r.getBoolean("deleteNonDurableQueue"), r.getBoolean("manage"), r.getBoolean("browse"), r.getBoolean("createAddress")); roles[i] = role; } return roles; }
if (result != null) { JsonObject location = result.getJsonObject(0).getJsonArray("resources").getJsonObject(0).getJsonObject("address"); if (location != null) { Address address = new Address();
JsonArray result = json.getJsonArray("results"); if (result != null) { JsonObject location = result.getJsonObject(0).getJsonObject("components"); if (location != null) { Address address = new Address(); if (result.getJsonObject(0).containsKey("formatted")) { address.setFormattedAddress(result.getJsonObject(0).getString("formatted"));
.getJsonObject("Response") .getJsonArray("View") .getJsonObject(0) .getJsonArray("Result") .getJsonObject(0) .getJsonObject("Location") .getJsonObject("Address");
position.setDeviceId(deviceSession.getDeviceId()); JsonObject record = records.getJsonObject(i); JsonObject field = fields.getJsonObject(j); switch (field.getInt("FType")) { case 0:
@Override public Address parseAddress(JsonObject json) { Address address = new Address(); JsonObject result = json.getJsonArray("result").getJsonObject(0); if (result.containsKey("streetName")) { address.setStreet(result.getString("streetName")); } if (result.containsKey("city")) { address.setSettlement(result.getString("city")); } if (result.containsKey("state")) { address.setState(result.getString("state")); } if (result.containsKey("countryCode")) { address.setCountry(result.getString("countryCode")); } if (result.containsKey("formatedFull")) { address.setFormattedAddress(result.getString("formatedFull")); } return address; }
@Override public Address parseAddress(JsonObject json) { Address address = new Address(); JsonObject result = json .getJsonObject("geocoding_results") .getJsonArray("RESULTS") .getJsonObject(0); JsonObject resultAddress = result.getJsonObject("ADDRESS"); if (result.containsKey("formatted_address")) { address.setFormattedAddress(result.getString("formatted_address")); } if (resultAddress.containsKey("street_number")) { address.setStreet(resultAddress.getString("street_number")); } if (resultAddress.containsKey("street_name")) { address.setStreet(resultAddress.getString("street_name")); } if (resultAddress.containsKey("locality")) { address.setSettlement(resultAddress.getString("locality")); } if (resultAddress.containsKey("admin_1")) { address.setState(resultAddress.getString("admin_1")); } if (resultAddress.containsKey("country")) { address.setCountry(resultAddress.getString("country")); } return address; }
@Override public Address parseAddress(JsonObject json) { JsonArray result = json.getJsonArray("features"); if (result != null && !result.isEmpty()) { JsonObject location = result.getJsonObject(0).getJsonObject("properties"); Address address = new Address(); address.setCountry("FR"); if (location.containsKey("postcode")) { address.setPostcode(location.getString("postcode")); } if (location.containsKey("context")) { address.setDistrict(location.getString("context")); } if (location.containsKey("name")) { address.setStreet(location.getString("name")); } if (location.containsKey("city")) { address.setSettlement(location.getString("city")); } if (location.containsKey("housenumber")) { address.setHouse(location.getString("housenumber")); } if (location.containsKey("label")) { address.setFormattedAddress(location.getString("label")); } return address; } return null; }