All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.binarywang.wx.miniapp.json.adaptor.WxMaCodeCommitRequestGsonAdapter Maven / Gradle / Ivy

There is a newer version: 4.6.7.B
Show newest version
package cn.binarywang.wx.miniapp.json.adaptor;

import cn.binarywang.wx.miniapp.bean.code.WxMaCodeCommitRequest;
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

import java.lang.reflect.Type;

/**
 * @author Charming
 * @since 2018-04-26 19:47
 */
public class WxMaCodeCommitRequestGsonAdapter implements JsonSerializer {

  @Override
  public JsonElement serialize(WxMaCodeCommitRequest request, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject requestJson = new JsonObject();
    requestJson.addProperty("template_id", request.getTemplateId());
    requestJson.addProperty("user_version", request.getUserVersion());
    requestJson.addProperty("user_desc", request.getUserDesc());
    if (request.getExtConfig() != null) {
      requestJson.addProperty("ext_json", WxMaGsonBuilder.create().toJson(request.getExtConfig()));
    }
    return requestJson;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy