use of com.google.gson.JsonPrimitive in project weixin-java-tools by chanjarster.
the class WxCpServiceImpl method userDelete.
@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());
}
use of com.google.gson.JsonPrimitive in project weixin-java-tools by chanjarster.
the class WxCpServiceImpl method tagAddUsers.
@Override
public void tagAddUsers(String tagId, List<String> userIds, List<String> partyIds) throws WxErrorException {
String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/addtagusers";
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("tagid", tagId);
if (userIds != null) {
JsonArray jsonArray = new JsonArray();
for (String userId : userIds) {
jsonArray.add(new JsonPrimitive(userId));
}
jsonObject.add("userlist", jsonArray);
}
if (partyIds != null) {
JsonArray jsonArray = new JsonArray();
for (String userId : partyIds) {
jsonArray.add(new JsonPrimitive(userId));
}
jsonObject.add("partylist", jsonArray);
}
post(url, jsonObject.toString());
}
use of com.google.gson.JsonPrimitive in project che by eclipse.
the class JsonRpcResultTest method shouldGetAsListOfStringWhenParsingStringWithResultAsString.
@Test
public void shouldGetAsListOfStringWhenParsingStringWithResultAsString() throws Exception {
String expected = "a";
JsonPrimitive primitive = new JsonPrimitive(expected);
JsonArray array = new JsonArray();
array.add(primitive);
JsonRpcResult jsonRpcResult = new JsonRpcResult(array.toString(), jsonParser);
List<String> actual = jsonRpcResult.getAsListOf(String.class);
assertEquals(expected, actual.iterator().next());
}
use of com.google.gson.JsonPrimitive in project che by eclipse.
the class JsonRpcResultTest method shouldToJsonValueWhenPassingParametersWithResultAsASingleString.
@Test
public void shouldToJsonValueWhenPassingParametersWithResultAsASingleString() throws Exception {
String value = "a";
JsonPrimitive expected = new JsonPrimitive(value);
JsonRpcResult jsonRpcResult = new JsonRpcResult(value, jsonParser);
JsonElement actual = jsonRpcResult.toJsonElement();
assertEquals(expected, actual);
}
use of com.google.gson.JsonPrimitive in project che by eclipse.
the class JsonRpcParamsTest method shouldToJsonForCreatedListDoubleParams.
@Test
public void shouldToJsonForCreatedListDoubleParams() throws Exception {
double value = 0D;
List<Double> list = singletonList(value);
JsonArray expected = new JsonArray();
expected.add(new JsonPrimitive(value));
JsonRpcParams jsonRpcParams = new JsonRpcParams(list, jsonParser);
JsonElement actual = jsonRpcParams.toJsonElement();
assertEquals(expected, actual);
}
Aggregations