@Override public void tagRemoveUsers(String tagId, List<String> userIds) throws WxErrorException { String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/deltagusers"; JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("tagid", tagId); JsonArray jsonArray = new JsonArray(); for (String userId : userIds) { jsonArray.add(new JsonPrimitive(userId)); } jsonObject.add("userlist", jsonArray); post(url, jsonObject.toString()); }
private static void addPatternListToSource(JsonObject sourceObject, String rule, List<String> patternList) { if (!patternList.isEmpty()) { JsonArray ruleArray; if (sourceObject.has(rule)) { ruleArray = sourceObject.get(rule).getAsJsonArray(); } else { ruleArray = new JsonArray(); sourceObject.add(rule, ruleArray); } for (String pattern : patternList) { ruleArray.add(pattern); } } }
Vertx vertx = Vertx.newVertx(); EventBus eventBus = vertx.eventBus() HttpServer server = vertx.createHttpServer(); JsonArray permitted = new JsonArray(); permitted.add(new JsonObject()); SockJSServer sockJSServer = new DefaultSockJSServer(vertx, server); sockJSServer.bridge(new JsonObject().putString("prefix", "/pusher"), permitted, permitted); server.listen(<some port>);
@Override public String getData(Gson gson) { String data; if (sortList.isEmpty() && includePatternList.isEmpty() && excludePatternList.isEmpty()) { data = query; } else { JsonObject queryObject = gson.fromJson(query, JsonObject.class); if (queryObject == null) { queryObject = new JsonObject(); } if (!sortList.isEmpty()) { JsonArray sortArray = normalizeSortClause(queryObject); for (Sort sort : sortList) { sortArray.add(sort.toJsonObject()); } } if (!includePatternList.isEmpty() || !excludePatternList.isEmpty()) { JsonObject sourceObject = normalizeSourceClause(queryObject); addPatternListToSource(sourceObject, "includes", includePatternList); addPatternListToSource(sourceObject, "excludes", excludePatternList); } data = gson.toJson(queryObject); } return data; }
@Override public void setProperty(final Object obj, final Object key, final Object value) { if (isMap(obj)) { toJsonObject(obj).add(key.toString(), createJsonElement(value)); } else { JsonArray array = toJsonArray(obj); int index; if (key != null) { index = key instanceof Integer ? (Integer) key : Integer.parseInt(key.toString()); } else { index = array.size(); } if (index == array.size()) { array.add(createJsonElement(value)); } else { array.set(index, createJsonElement(value)); } } }
public String toJson() { JsonObject details = new JsonObject(); details.addProperty(FIELD_LEVEL, level.toString()); JsonArray conditionResults = new JsonArray(); for (EvaluatedCondition condition : this.conditions) { conditionResults.add(toJson(condition)); } details.add("conditions", conditionResults); details.addProperty(FIELD_IGNORED_CONDITIONS, ignoredConditions); return details.toString(); }
private void addEnvironment(Properties envProps) { JsonArray containerEnv = new JsonArray(); Enumeration keys = envProps.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = envProps.getProperty(key); if (value == null) { value = ""; } containerEnv.add(key + "=" + value); } createConfig.add("Env", containerEnv); }
public static JsonObject addObj(JsonArray arr) { JsonObject res = new JsonObject(); arr.add(res); return res; }
private void put(JsonElement value) { if (pendingName != null) { if (!value.isJsonNull() || getSerializeNulls()) { JsonObject object = (JsonObject) peek(); object.add(pendingName, value); } pendingName = null; } else if (stack.isEmpty()) { product = value; } else { JsonElement element = peek(); if (element instanceof JsonArray) { ((JsonArray) element).add(value); } else { throw new IllegalStateException(); } } }
@Override public void userDelete(String[] userids) throws WxErrorException { String url = "https://qyapi.weixin.qq.com/cgi-bin/user/batchdelete"; JsonObject jsonObject = new JsonObject(); JsonArray jsonArray = new JsonArray(); for (int i = 0; i < userids.length; i++) { jsonArray.add(new JsonPrimitive(userids[i])); } jsonObject.add("useridlist", jsonArray); post(url, jsonObject.toString()); }
private void addFilters(Builder builder, String... filter) { if (filter.length > 0) { if (filter.length % 2 != 0) { throw new IllegalArgumentException("Filters must be given as key value pairs and not " + Arrays.asList(filter)); } JsonObject filters = new JsonObject(); for (int i = 0; i < filter.length; i +=2) { JsonArray value = new JsonArray(); value.add(filter[i+1]); filters.add(filter[i],value); } builder.p("filters",filters.toString()); } }
@Override public JsonElement serialize(Filters src, Type typeOfSrc, JsonSerializationContext context) { final JsonObject result = new JsonObject(); final JsonArray viewFilters = new JsonArray(); for (DashboardFilter f : src.filters()) { viewFilters.add(context.serialize(f, DashboardFilter.class)); } result.add(KEY_FILTERS, viewFilters); return result; } }