gson デコード 単レコード

[ JSONリクエストパラメーター値 (実際は未整形)]


{
    "cd_unlo": "JPUKB",
    "tp_facil": "OT",
    "lat": 34.729880639820365,
    "lon": 135.25307087456054,
    "nm_facil": "未決定 788",
    "nm_facil_e": "UNKNOWN 788"
}

[ JSONリクエストデコードサンプル ]


  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {

    // ++ リクエストパラメータ取得 ++ //
    String latlonsjsn = request.getParameter("latlons");        

    // JSONデコードはリフレクションで行う // 
    PortLatLon PLL = new PortLatLon();
    Gson gson = new GsonBuilder().setPrettyPrinting().create();
    Type type = new TypeToken<PortLatLon>() {
    }.getType();
    PLL = gson.fromJson(latlonsjsn, type);

[ JAVAクラス ]


package vesselsch;

/**
 * GoogleMap用陸上施設型 
 * @author 田中尚
 */
public class Facility {
  
  private int id;
  private int fid;
  private String tp_facil;
  private String nm_facil;
  private String no_zip;
  private String nm_addr;
  private double lat = 0;
  private double lon = 0;
  private String nm_url;
  private String no_tel;
  private String tm_add;
  private String tm_updt;
  private String tm_lastupdt;
  private String nm_rmtaddr;
  private String nm_remark;
  private String cd_unlo;
  
  private String nm_facil_e = "";
  private String nm_addr_e = "";
  
  private String file1 = "";
  private short is_imgexist;
  
  // 保税蔵置場経緯度更新時リフレクションでセットする用 //
  private String flgbarea;
  private String cd_naccs;
  // US Broker経緯度更新時リフレクションでセットする用 //
  private String flgusbroker;
  
  

  /**
   * @return the id
   */
  public int getId() {
    return id;
  }

  /**
   * @param id the id to set
   */
  public void setId(int id) {
    this.id = id;
  }

  /**
   * @return the fid
   */
  public int getFid() {
    return fid;
  }

  /**
   * @param fid the fid to set
   */
  public void setFid(int fid) {
    this.fid = fid;
  }

  /**
   * @return the tp_facil
   */
  public String getTp_facil() {
    return tp_facil;
  }

  /**
   * @param tp_facil the tp_facil to set
   */
  public void setTp_facil(String tp_facil) {
    this.tp_facil = tp_facil;
  }

  /**
   * @return the nm_facil
   */
  public String getNm_facil() {
    return nm_facil;
  }

  /**
   * @param nm_facil the nm_facil to set
   */
  public void setNm_facil(String nm_facil) {
    this.nm_facil = nm_facil;
  }

  /**
   * @return the no_zip
   */
  public String getNo_zip() {
    return no_zip;
  }

  /**
   * @param no_zip the no_zip to set
   */
  public void setNo_zip(String no_zip) {
    this.no_zip = no_zip;
  }

  /**
   * @return the nm_addr
   */
  public String getNm_addr() {
    return nm_addr;
  }

  /**
   * @param nm_addr the nm_addr to set
   */
  public void setNm_addr(String nm_addr) {
    this.nm_addr = nm_addr;
  }

  /**
   * @return the lat
   */
  public double getLat() {
    return lat;
  }

  /**
   * @param lat the lat to set
   */
  public void setLat(double lat) {
    this.lat = lat;
  }

  /**
   * @return the lon
   */
  public double getLon() {
    return lon;
  }

  /**
   * @param lon the lon to set
   */
  public void setLon(double lon) {
    this.lon = lon;
  }

  /**
   * @return the nm_url
   */
  public String getNm_url() {
    return nm_url;
  }

  /**
   * @param nm_url the nm_url to set
   */
  public void setNm_url(String nm_url) {
    this.nm_url = nm_url;
  }

  /**
   * @return the no_tel
   */
  public String getNo_tel() {
    return no_tel;
  }

  /**
   * @param no_tel the no_tel to set
   */
  public void setNo_tel(String no_tel) {
    this.no_tel = no_tel;
  }

  /**
   * @return the tm_add
   */
  public String getTm_add() {
    return tm_add;
  }

  /**
   * @param tm_add the tm_add to set
   */
  public void setTm_add(String tm_add) {
    this.tm_add = tm_add;
  }

  /**
   * @return the tm_updt
   */
  public String getTm_updt() {
    return tm_updt;
  }

  /**
   * @param tm_updt the tm_updt to set
   */
  public void setTm_updt(String tm_updt) {
    this.tm_updt = tm_updt;
  }

  /**
   * @return the tm_lastupdt
   */
  public String getTm_lastupdt() {
    return tm_lastupdt;
  }

  /**
   * @param tm_lastupdt the tm_lastupdt to set
   */
  public void setTm_lastupdt(String tm_lastupdt) {
    this.tm_lastupdt = tm_lastupdt;
  }

  /**
   * @return the nm_rmtaddr
   */
  public String getNm_rmtaddr() {
    return nm_rmtaddr;
  }

  /**
   * @param nm_rmtaddr the nm_rmtaddr to set
   */
  public void setNm_rmtaddr(String nm_rmtaddr) {
    this.nm_rmtaddr = nm_rmtaddr;
  }

  /**
   * @return the nm_remark
   */
  public String getNm_remark() {
    return nm_remark;
  }

  /**
   * @param nm_remark the nm_remark to set
   */
  public void setNm_remark(String nm_remark) {
    this.nm_remark = nm_remark;
  }

  /**
   * @return the cd_unlo
   */
  public String getCd_unlo() {
    return cd_unlo;
  }

  /**
   * @param cd_unlo the cd_unlo to set
   */
  public void setCd_unlo(String cd_unlo) {
    this.cd_unlo = cd_unlo;
  }

  /**
   * @return the nm_facil_e
   */
  public String getNm_facil_e() {
    return nm_facil_e;
  }

  /**
   * @param nm_facil_e the nm_facil_e to set
   */
  public void setNm_facil_e(String nm_facil_e) {
    this.nm_facil_e = nm_facil_e;
  }

  /**
   * @return the nm_addr_e
   */
  public String getNm_addr_e() {
    return nm_addr_e;
  }

  /**
   * @param nm_addr_e the nm_addr_e to set
   */
  public void setNm_addr_e(String nm_addr_e) {
    this.nm_addr_e = nm_addr_e;
  }

  /**
   * @return the file1
   */
  public String getFile1() {
    return file1;
  }

  /**
   * @param file1 the file1 to set
   */
  public void setFile1(String file1) {
    this.file1 = file1;
  }

  /**
   * @return the is_imgexist
   */
  public short getIs_imgexist() {
    return is_imgexist;
  }

  /**
   * @param is_imgexist the is_imgexist to set
   */
  public void setIs_imgexist(short is_imgexist) {
    this.is_imgexist = is_imgexist;
  }

  /**
   * @return the flgbarea
   */
  public String getFlgbarea() {
    return flgbarea;
  }

  /**
   * @param flgbarea the flgbarea to set
   */
  public void setFlgbarea(String flgbarea) {
    this.flgbarea = flgbarea;
  }

  /**
   * @return the cd_naccs
   */
  public String getCd_naccs() {
    return cd_naccs;
  }

  /**
   * @param cd_naccs the cd_naccs to set
   */
  public void setCd_naccs(String cd_naccs) {
    this.cd_naccs = cd_naccs;
  }

  /**
   * @return the flgusbroker
   */
  public String getFlgusbroker() {
    return flgusbroker;
  }

  /**
   * @param flgusbroker the flgusbroker to set
   */
  public void setFlgusbroker(String flgusbroker) {
    this.flgusbroker = flgusbroker;
  }
  
  
  
  
  
}
 

コメントを残す