• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java WxMpGsonBuilder类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中me.chanjar.weixin.mp.util.json.WxMpGsonBuilder的典型用法代码示例。如果您正苦于以下问题:Java WxMpGsonBuilder类的具体用法?Java WxMpGsonBuilder怎么用?Java WxMpGsonBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

WxMpGsonBuilder类属于me.chanjar.weixin.mp.util.json包,在下文中一共展示了WxMpGsonBuilder类的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: execute

点赞 3

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public WxMpMaterialNews execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String materialId) throws WxErrorException, IOException {
  HttpPost httpPost = new HttpPost(uri);
  if (httpProxy != null) {
    RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();
    httpPost.setConfig(config);
  }

  Map<String, String> params = new HashMap<>();
  params.put("media_id", materialId);
  httpPost.setEntity(new StringEntity(WxGsonBuilder.create().toJson(params)));
  try(CloseableHttpResponse response = httpclient.execute(httpPost)){
    String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
    WxError error = WxError.fromJson(responseContent);
    if (error.getErrorCode() != 0) {
      throw new WxErrorException(error);
    } else {
      return WxMpGsonBuilder.create().fromJson(responseContent, WxMpMaterialNews.class);
    }
  }finally {
    httpPost.releaseConnection();
  }

}
 

开发者ID:11590692,
项目名称:Wechat-Group,
代码行数:25,
代码来源:MaterialNewsInfoRequestExecutor.java

示例2: markCardCode

点赞 3

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
/**
 * 卡券Mark接口。
 * 开发者在帮助消费者核销卡券之前,必须帮助先将此code(卡券串码)与一个openid绑定(即mark住),
 * 才能进一步调用核销接口,否则报错。
 *
 * @param code   卡券的code码
 * @param cardId 卡券的ID
 * @param openId 用券用户的openid
 * @param isMark 是否要mark(占用)这个code,填写true或者false,表示占用或解除占用
 */
@Override
public void markCardCode(String code, String cardId, String openId, boolean isMark) throws
        WxErrorException {
  String url = "https://api.weixin.qq.com/card/code/mark";
  JsonObject param = new JsonObject();
  param.addProperty("code", code);
  param.addProperty("card_id", cardId);
  param.addProperty("openid", openId);
  param.addProperty("is_mark", isMark);
  String responseContent = this.wxMpService.post(url, param.toString());
  JsonElement tmpJsonElement = new JsonParser().parse(responseContent);
  WxMpCardResult cardResult = WxMpGsonBuilder.INSTANCE.create().fromJson(tmpJsonElement,
          new TypeToken<WxMpCardResult>() { }.getType());
  if (!cardResult.getErrorCode().equals("0")) {
    this.log.warn("朋友的券mark失败:{}", cardResult.getErrorMsg());
  }
}
 

开发者ID:11590692,
项目名称:Wechat-Group,
代码行数:28,
代码来源:WxMpCardServiceImpl.java

示例3: markCardCode

点赞 3

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
/**
 * 卡券Mark接口。
 * 开发者在帮助消费者核销卡券之前,必须帮助先将此code(卡券串码)与一个openid绑定(即mark住),
 * 才能进一步调用核销接口,否则报错。
 *
 * @param code   卡券的code码
 * @param cardId 卡券的ID
 * @param openId 用券用户的openid
 * @param isMark 是否要mark(占用)这个code,填写true或者false,表示占用或解除占用
 */
@Override
public void markCardCode(String code, String cardId, String openId, boolean isMark) throws
  WxErrorException {
  JsonObject param = new JsonObject();
  param.addProperty("code", code);
  param.addProperty("card_id", cardId);
  param.addProperty("openid", openId);
  param.addProperty("is_mark", isMark);
  String responseContent = this.getWxMpService().post(CARD_CODE_MARK, param.toString());
  JsonElement tmpJsonElement = new JsonParser().parse(responseContent);
  WxMpCardResult cardResult = WxMpGsonBuilder.INSTANCE.create().fromJson(tmpJsonElement,
    new TypeToken<WxMpCardResult>() {
    }.getType());
  if (!cardResult.getErrorCode().equals("0")) {
    this.log.warn("朋友的券mark失败:{}", cardResult.getErrorMsg());
  }
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools,
代码行数:28,
代码来源:WxMpCardServiceImpl.java

示例4: execute

点赞 3

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public WxMpMaterialNews execute(String uri, String materialId) throws WxErrorException, IOException {

  //得到httpClient
  OkHttpClient client = requestHttp.getRequestHttpClient();

  RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"),
    WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId)));
  Request request = new Request.Builder().url(uri).post(requestBody).build();

  Response response = client.newCall(request).execute();
  String responseContent = response.body().string();
  this.logger.debug("响应原始数据:{}", responseContent);

  WxError error = WxError.fromJson(responseContent);
  if (error.getErrorCode() != 0) {
    throw new WxErrorException(error);
  } else {
    return WxMpGsonBuilder.create().fromJson(responseContent, WxMpMaterialNews.class);
  }
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools,
代码行数:22,
代码来源:OkhttpMaterialNewsInfoRequestExecutor.java

示例5: execute

点赞 3

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public WxMpMaterialNews execute(String uri, String materialId) throws WxErrorException, IOException {
  HttpPost httpPost = new HttpPost(uri);
  if (requestHttp.getRequestHttpProxy() != null) {
    RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
    httpPost.setConfig(config);
  }

  httpPost.setEntity(new StringEntity(WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId))));
  try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost)) {
    String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
    this.logger.debug("响应原始数据:{}", responseContent);
    WxError error = WxError.fromJson(responseContent);
    if (error.getErrorCode() != 0) {
      throw new WxErrorException(error);
    } else {
      return WxMpGsonBuilder.create().fromJson(responseContent, WxMpMaterialNews.class);
    }
  } finally {
    httpPost.releaseConnection();
  }
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools,
代码行数:23,
代码来源:ApacheMaterialNewsInfoRequestExecutor.java

示例6: execute

点赞 3

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public WxMpMaterialNews execute(String uri, String materialId) throws WxErrorException, IOException {
  if (requestHttp.getRequestHttpProxy() != null) {
    requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy());
  }

  HttpRequest request = HttpRequest.post(uri)
    .withConnectionProvider(requestHttp.getRequestHttpClient())
    .body(WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId)));
  HttpResponse response = request.send();
  response.charset(StringPool.UTF_8);

  String responseContent = response.bodyText();
  this.logger.debug("响应原始数据:{}", responseContent);
  WxError error = WxError.fromJson(responseContent);
  if (error.getErrorCode() != 0) {
    throw new WxErrorException(error);
  } else {
    return WxMpGsonBuilder.create().fromJson(responseContent, WxMpMaterialNews.class);
  }
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools,
代码行数:22,
代码来源:JoddMaterialNewsInfoRequestExecutor.java

示例7: userTagList

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public List<Long> userTagList(String openid) throws WxErrorException {
  String url = API_URL_PREFIX + "/getidlist";

  JsonObject json = new JsonObject();
  json.addProperty("openid", openid);

  String responseContent = this.wxMpService.post(url, json.toString());

  return WxMpGsonBuilder.create().fromJson(
      new JsonParser().parse(responseContent).getAsJsonObject().get("tagid_list"),
      new TypeToken<List<Long>>() {
  }.getType());
}
 

开发者ID:11590692,
项目名称:Wechat-Group,
代码行数:15,
代码来源:WxMpUserTagServiceImpl.java

示例8: queryCardCode

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
/**
 * 卡券Code查询
 *
 * @param cardId       卡券ID代表一类卡券
 * @param code         单张卡券的唯一标准
 * @param checkConsume 是否校验code核销状态,填入true和false时的code异常状态返回数据不同
 * @return WxMpCardResult对象
 */
@Override
public WxMpCardResult queryCardCode(String cardId, String code, boolean checkConsume) throws WxErrorException {
  String url = "https://api.weixin.qq.com/card/code/get";
  JsonObject param = new JsonObject();
  param.addProperty("card_id", cardId);
  param.addProperty("code", code);
  param.addProperty("check_consume", checkConsume);
  String responseContent = this.wxMpService.post(url, param.toString());
  JsonElement tmpJsonElement = new JsonParser().parse(responseContent);
  return WxMpGsonBuilder.INSTANCE.create().fromJson(tmpJsonElement,
          new TypeToken<WxMpCardResult>() {
          }.getType());
}
 

开发者ID:11590692,
项目名称:Wechat-Group,
代码行数:22,
代码来源:WxMpCardServiceImpl.java

示例9: listCategories

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public List<String> listCategories() throws WxErrorException {
  String url = API_BASE_URL + "/getwxcategory";
  String response = this.wxMpService.get(url, null);
  WxError wxError = WxError.fromJson(response);
  if (wxError.getErrorCode() != 0) {
    throw new WxErrorException(wxError);
  }

  return WxMpGsonBuilder.create().fromJson(
      new JsonParser().parse(response).getAsJsonObject().get("category_list"),
      new TypeToken<List<String>>(){}.getType());
}
 

开发者ID:11590692,
项目名称:Wechat-Group,
代码行数:14,
代码来源:WxMpStoreServiceImpl.java

示例10: materialCount

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public WxMpMaterialCountResult materialCount() throws WxErrorException {
  String url = MATERIAL_API_URL_PREFIX + "/get_materialcount";
  String responseText = this.wxMpService.get(url, null);
  WxError wxError = WxError.fromJson(responseText);
  if (wxError.getErrorCode() == 0) {
    return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialCountResult.class);
  } else {
    throw new WxErrorException(wxError);
  }
}
 

开发者ID:11590692,
项目名称:Wechat-Group,
代码行数:12,
代码来源:WxMpMaterialServiceImpl.java

示例11: materialNewsBatchGet

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count) throws WxErrorException {
  String url = MATERIAL_API_URL_PREFIX + "/batchget_material";
  Map<String, Object> params = new HashMap<>();
  params.put("type", WxConsts.MATERIAL_NEWS);
  params.put("offset", offset);
  params.put("count", count);
  String responseText = this.wxMpService.post(url, WxGsonBuilder.create().toJson(params));
  WxError wxError = WxError.fromJson(responseText);
  if (wxError.getErrorCode() == 0) {
    return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialNewsBatchGetResult.class);
  } else {
    throw new WxErrorException(wxError);
  }
}
 

开发者ID:11590692,
项目名称:Wechat-Group,
代码行数:16,
代码来源:WxMpMaterialServiceImpl.java

示例12: materialFileBatchGet

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count) throws WxErrorException {
  String url = MATERIAL_API_URL_PREFIX + "/batchget_material";
  Map<String, Object> params = new HashMap<>();
  params.put("type", type);
  params.put("offset", offset);
  params.put("count", count);
  String responseText = this.wxMpService.post(url, WxGsonBuilder.create().toJson(params));
  WxError wxError = WxError.fromJson(responseText);
  if (wxError.getErrorCode() == 0) {
    return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialFileBatchGetResult.class);
  } else {
    throw new WxErrorException(wxError);
  }
}
 

开发者ID:11590692,
项目名称:Wechat-Group,
代码行数:16,
代码来源:WxMpMaterialServiceImpl.java

示例13: fromJsonList

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
public static List<WxMpUser> fromJsonList(String json) {
  Type collectionType = new TypeToken<List<WxMpUser>>() {
  }.getType();
  Gson gson = WxMpGsonBuilder.INSTANCE.create();
  JsonObject jsonObject = gson.fromJson(json, JsonObject.class);
  return gson.fromJson(jsonObject.get("user_info_list"), collectionType);
}
 

开发者ID:11590692,
项目名称:Wechat-Group,
代码行数:8,
代码来源:WxMpUser.java

示例14: toJson

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
public String toJson() {
  JsonElement base_info = WxMpGsonBuilder.create().toJsonTree(this);
  JsonObject jsonObject = new JsonObject();
  jsonObject.add("base_info", base_info);
  JsonObject business = new JsonObject();
  business.add("business", jsonObject);
  return business.toString();
}
 

开发者ID:11590692,
项目名称:Wechat-Group,
代码行数:9,
代码来源:WxMpStoreBaseInfo.java

示例15: userTagList

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public List<Long> userTagList(String openid) throws WxErrorException {
  String url = API_URL_PREFIX + "/getidlist";

  JsonObject json = new JsonObject();
  json.addProperty("openid", openid);

  String responseContent = this.wxMpService.post(url, json.toString());

  return WxMpGsonBuilder.create().fromJson(
    new JsonParser().parse(responseContent).getAsJsonObject().get("tagid_list"),
    new TypeToken<List<Long>>() {
    }.getType());
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools,
代码行数:15,
代码来源:WxMpUserTagServiceImpl.java

示例16: queryCardCode

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
/**
 * 卡券Code查询
 *
 * @param cardId       卡券ID代表一类卡券
 * @param code         单张卡券的唯一标准
 * @param checkConsume 是否校验code核销状态,填入true和false时的code异常状态返回数据不同
 * @return WxMpCardResult对象
 */
@Override
public WxMpCardResult queryCardCode(String cardId, String code, boolean checkConsume) throws WxErrorException {
  JsonObject param = new JsonObject();
  param.addProperty("card_id", cardId);
  param.addProperty("code", code);
  param.addProperty("check_consume", checkConsume);
  String responseContent = this.wxMpService.post(CARD_CODE_GET, param.toString());
  JsonElement tmpJsonElement = new JsonParser().parse(responseContent);
  return WxMpGsonBuilder.INSTANCE.create().fromJson(tmpJsonElement,
    new TypeToken<WxMpCardResult>() {
    }.getType());
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools,
代码行数:21,
代码来源:WxMpCardServiceImpl.java

示例17: getUserInfo

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
/**
 * 拉取会员信息接口
 *
 * @param cardId 会员卡的CardId,微信分配
 * @param code   领取会员的会员卡Code
 * @return 会员信息的结果对象
 * @throws WxErrorException 接口调用失败抛出的异常
 */
@Override
public WxMpMemberCardUserInfoResult getUserInfo(String cardId, String code) throws WxErrorException {
  JsonObject jsonObject = new JsonObject();
  jsonObject.addProperty("card_id", cardId);
  jsonObject.addProperty("code",code);

  String responseContent = this.getWxMpService().post(MEMBER_CARD_USER_INFO_GET, jsonObject.toString());
  JsonElement tmpJsonElement = new JsonParser().parse(responseContent);
  return WxMpGsonBuilder.INSTANCE.create().fromJson(tmpJsonElement,
    new TypeToken<WxMpMemberCardUserInfoResult>() {
    }.getType());
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools,
代码行数:21,
代码来源:WxMpMemberCardServiceImpl.java

示例18: updateUserMemberCard

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
/**
 * 当会员持卡消费后,支持开发者调用该接口更新会员信息。会员卡交易后的每次信息变更需通过该接口通知微信,便于后续消息通知及其他扩展功能。
 *
 * 1.开发者可以同时传入add_bonus和bonus解决由于同步失败带来的幂等性问题。同时传入add_bonus和bonus时
 * add_bonus作为积分变动消息中的变量值,而bonus作为卡面上的总积分额度显示。余额变动同理。
 * 2.开发者可以传入is_notify_bonus控制特殊的积分对账变动不发送消息,余额变动同理。
 *
 * @param updateUserMessage 更新会员信息所需字段消息
 * @return 调用返回的JSON字符串。
 * @throws WxErrorException 接口调用失败抛出的异常
 */
@Override
public WxMpMemberCardUpdateResult updateUserMemberCard(WxMpMemberCardUpdateMessage updateUserMessage)
  throws WxErrorException {

  String responseContent = this.getWxMpService().post(MEMBER_CARD_UPDATE_USER, GSON.toJson(updateUserMessage));

  JsonElement tmpJsonElement = new JsonParser().parse(responseContent);
  return WxMpGsonBuilder.INSTANCE.create().fromJson(tmpJsonElement,
    new TypeToken<WxMpMemberCardUpdateResult>() {
    }.getType());
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools,
代码行数:23,
代码来源:WxMpMemberCardServiceImpl.java

示例19: listCategories

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public List<String> listCategories() throws WxErrorException {
  String response = this.wxMpService.get(POI_GET_WX_CATEGORY_URL, null);
  WxError wxError = WxError.fromJson(response);
  if (wxError.getErrorCode() != 0) {
    throw new WxErrorException(wxError);
  }

  return WxMpGsonBuilder.create().fromJson(
    new JsonParser().parse(response).getAsJsonObject().get("category_list"),
    new TypeToken<List<String>>() {
    }.getType());
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools,
代码行数:14,
代码来源:WxMpStoreServiceImpl.java

示例20: materialCount

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public WxMpMaterialCountResult materialCount() throws WxErrorException {
  String responseText = this.wxMpService.get(MATERIAL_GET_COUNT_URL, null);
  WxError wxError = WxError.fromJson(responseText);
  if (wxError.getErrorCode() == 0) {
    return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialCountResult.class);
  } else {
    throw new WxErrorException(wxError);
  }
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools,
代码行数:11,
代码来源:WxMpMaterialServiceImpl.java

示例21: materialNewsBatchGet

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count) throws WxErrorException {
  Map<String, Object> params = new HashMap<>();
  params.put("type", WxConsts.MaterialType.NEWS);
  params.put("offset", offset);
  params.put("count", count);
  String responseText = this.wxMpService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params));
  WxError wxError = WxError.fromJson(responseText);
  if (wxError.getErrorCode() == 0) {
    return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialNewsBatchGetResult.class);
  } else {
    throw new WxErrorException(wxError);
  }
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools,
代码行数:15,
代码来源:WxMpMaterialServiceImpl.java

示例22: materialFileBatchGet

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count) throws WxErrorException {
  Map<String, Object> params = new HashMap<>();
  params.put("type", type);
  params.put("offset", offset);
  params.put("count", count);
  String responseText = this.wxMpService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params));
  WxError wxError = WxError.fromJson(responseText);
  if (wxError.getErrorCode() == 0) {
    return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialFileBatchGetResult.class);
  } else {
    throw new WxErrorException(wxError);
  }
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools,
代码行数:15,
代码来源:WxMpMaterialServiceImpl.java

示例23: fromJson

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
public static WxMpShakeAroundPageAddResult fromJson(String json) {
  JsonObject jsonObject = WxMpGsonBuilder.INSTANCE.create().fromJson(json, JsonObject.class);
  WxMpShakeAroundPageAddResult result = new WxMpShakeAroundPageAddResult();
  result.setErrorCode(GsonHelper.getInteger(jsonObject, "errcode"));
  result.setErrorMsg(GsonHelper.getString(jsonObject, "errmsg"));
  jsonObject = jsonObject.getAsJsonObject("data");
  if(jsonObject != null){
    result.setPageId(GsonHelper.getInteger(jsonObject, "page_id"));
  }
  return result;
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools,
代码行数:12,
代码来源:WxMpShakeAroundPageAddResult.java

示例24: toJson

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
public String toJson() {
  JsonElement baseInfo = WxMpGsonBuilder.create().toJsonTree(this);
  JsonObject jsonObject = new JsonObject();
  jsonObject.add("base_info", baseInfo);
  JsonObject business = new JsonObject();
  business.add("business", jsonObject);
  return business.toString();
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools,
代码行数:9,
代码来源:WxMpStoreBaseInfo.java

示例25: userTagList

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public List<Integer> userTagList(String openid) throws WxErrorException {
  String url = "https://api.weixin.qq.com/cgi-bin/tags/getidlist";

  JsonObject json = new JsonObject();
  json.addProperty("openid", openid);

  String responseContent = this.wxMpService.post(url, json.toString());

  return WxMpGsonBuilder.create().fromJson(
      new JsonParser().parse(responseContent).getAsJsonObject().get("tagid_list"),
      new TypeToken<List<Integer>>() {
  }.getType());
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools-for-JDK6,
代码行数:15,
代码来源:WxMpUserTagServiceImpl.java

示例26: materialNewsBatchGet

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
@Override
public WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count) throws WxErrorException {
  String url = MATERIAL_API_URL_PREFIX + "/batchget_material";
  Map<String, Object> params = new HashMap<String, Object>();
  params.put("type", WxConsts.MATERIAL_NEWS);
  params.put("offset", offset);
  params.put("count", count);
  String responseText = this.wxMpService.post(url, WxGsonBuilder.create().toJson(params));
  WxError wxError = WxError.fromJson(responseText);
  if (wxError.getErrorCode() == 0) {
    return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialNewsBatchGetResult.class);
  } else {
    throw new WxErrorException(wxError);
  }
}
 

开发者ID:binarywang,
项目名称:weixin-java-tools-for-JDK6,
代码行数:16,
代码来源:WxMpMaterialServiceImpl.java

示例27: toJson

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
public String toJson() {
  return WxMpGsonBuilder.INSTANCE.create().toJson(this);
}
 

开发者ID:11590692,
项目名称:Wechat-Group,
代码行数:4,
代码来源:WxMpMassPreviewMessage.java

示例28: fromJson

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
public static WxDeviceQrCodeResult fromJson(String json) {
  return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxDeviceQrCodeResult.class);
}
 

开发者ID:11590692,
项目名称:Wechat-Group,
代码行数:4,
代码来源:WxDeviceQrCodeResult.java

示例29: fromJson

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
public static WxDeviceBindResult fromJson(String json) {
  return WxMpGsonBuilder.create().fromJson(json, WxDeviceBindResult.class);
}
 

开发者ID:11590692,
项目名称:Wechat-Group,
代码行数:4,
代码来源:WxDeviceBindResult.java

示例30: fromJson

点赞 2

import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; //导入依赖的package包/类
public static List<WxDataCubeUserCumulate> fromJson(String json) {
  return WxMpGsonBuilder.INSTANCE.create().fromJson(
      JSON_PARSER.parse(json).getAsJsonObject().get("list"),
      new TypeToken<List<WxDataCubeUserCumulate>>() {
      }.getType());
}
 

开发者ID:11590692,
项目名称:Wechat-Group,
代码行数:7,
代码来源:WxDataCubeUserCumulate.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)