Example usage for com.google.gson GsonBuilder create

List of usage examples for com.google.gson GsonBuilder create

Introduction

In this page you can find the example usage for com.google.gson GsonBuilder create.

Prototype

public Gson create() 

Source Link

Document

Creates a Gson instance based on the current configuration.

Usage

From source file:com.jobchat.action.MobileAction.java

private void addUserhobbytype(JSONObject data) throws JSONException {
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();
    String s = data.toString();/*from   ww  w .  jav  a2  s.  c  o  m*/
    JUserhobbytype en = gson.fromJson(s, new TypeToken<JUserhobbytype>() {
    }.getType());
    en.setStatus((short) 0);
    String ptime = TextUtility.formatDate(new Date());
    en.setPtime(ptime);
    boolean b = userhobbytypeService.addUserhobbytype(en);
    Map<String, Object> map = new HashMap<String, Object>();
    int status = 1;
    if (b) {
        status = 0;
        map.put("msg", "");
    } else {
        status = 1;
        map.put("msg", "");
    }
    map.put("ret", status);
    try {
        ResultUtils.toJson(ServletActionContext.getResponse(), map);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.jobchat.action.MobileAction.java

private void upUserhobbytype(JSONObject data) throws JSONException {
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();
    String s = data.toString();//w  w  w.  j a v  a  2  s. c om
    JUserhobbytype en = gson.fromJson(s, new TypeToken<JUserhobbytype>() {
    }.getType());

    String ptime = TextUtility.formatDate(new Date());
    en.setPtime(ptime);
    boolean b = userhobbytypeService.updateUserhobbytype(en);

    Map<String, Object> map = new HashMap<String, Object>();
    int status = 1;
    if (b) {
        status = 0;
    } else {
        status = 1;
    }
    map.put("ret", status);
    map.put("msg", "");
    try {
        ResultUtils.toJson(ServletActionContext.getResponse(), map);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.jobchat.action.MobileAction.java

private void addUserpapertype(JSONObject data) throws JSONException {
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();
    String s = data.toString();/*  ww  w. j a  va 2 s  . co m*/
    JUserhobbytype en = gson.fromJson(s, new TypeToken<JUserhobbytype>() {
    }.getType());
    en.setStatus((short) 0);
    String ptime = TextUtility.formatDate(new Date());
    en.setPtime(ptime);
    boolean b = userhobbytypeService.addUserhobbytype(en);
    Map<String, Object> map = new HashMap<String, Object>();
    int status = 1;
    if (b) {
        status = 0;
        map.put("msg", "");
    } else {
        status = 1;
        map.put("msg", "");
    }
    map.put("ret", status);
    try {
        ResultUtils.toJson(ServletActionContext.getResponse(), map);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.jobchat.action.MobileAction.java

private void upUserpapertype(JSONObject data) throws JSONException {
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();
    String s = data.toString();//from   w  ww . jav  a2  s  . c o m
    JUserpapertype en = gson.fromJson(s, new TypeToken<JUserpapertype>() {
    }.getType());

    String ptime = TextUtility.formatDate(new Date());
    en.setPtime(ptime);
    boolean b = userpapertypeService.updateUserpapertype(en);
    Map<String, Object> map = new HashMap<String, Object>();
    int status = 1;
    if (b) {
        status = 0;
    } else {
        status = 1;
    }
    map.put("ret", status);
    map.put("msg", "");
    try {
        ResultUtils.toJson(ServletActionContext.getResponse(), map);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.jobchat.action.MobileAction.java

private void addUserskilltype(JSONObject data) throws JSONException {
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();
    String s = data.toString();//w  ww  .j a v  a2 s. co m
    JUserskilltype en = gson.fromJson(s, new TypeToken<JUserskilltype>() {
    }.getType());
    en.setStatus((short) 0);
    String ptime = TextUtility.formatDate(new Date());
    en.setPtime(ptime);
    boolean b = userskilltypeService.addUserskilltype(en);
    Map<String, Object> map = new HashMap<String, Object>();
    int status = 1;
    if (b) {
        status = 10;
        map.put("msg", "");
    } else {
        status = 1;
        map.put("msg", "");
    }
    map.put("ret", status);
    try {
        ResultUtils.toJson(ServletActionContext.getResponse(), map);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.jobchat.action.MobileAction.java

private void upUserskilltype(JSONObject data) throws JSONException {
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();
    String s = data.toString();//  w  ww. j  a  va  2s .c o  m
    JUserskilltype en = gson.fromJson(s, new TypeToken<JUserskilltype>() {
    }.getType());

    String ptime = TextUtility.formatDate(new Date());
    en.setPtime(ptime);
    boolean b = userskilltypeService.updateUserskilltype(en);
    Map<String, Object> map = new HashMap<String, Object>();
    int status = 1;
    if (b) {
        status = 0;
    } else {
        status = 1;
    }
    map.put("ret", status);
    map.put("msg", "");
    try {
        ResultUtils.toJson(ServletActionContext.getResponse(), map);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.jobchat.action.MobileAction.java

private void addCompanyjobtype(JSONObject data) throws JSONException {
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();
    String s = data.toString();//from w  ww. j  a  va 2 s .c  o m
    JCompanyjobtype en = gson.fromJson(s, new TypeToken<JCompanyjobtype>() {
    }.getType());
    en.setStatus((short) 0);
    String ptime = TextUtility.formatDate(new Date());
    en.setPtime(ptime);
    boolean b = companyjobtypeService.addJCompanyjobtype(en);
    Map<String, Object> map = new HashMap<String, Object>();
    int status = 1;
    if (b) {
        status = 0;
        map.put("msg", "");
    } else {
        status = 1;
        map.put("msg", "");
    }
    map.put("ret", status);
    try {
        ResultUtils.toJson(ServletActionContext.getResponse(), map);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.jobchat.action.MobileAction.java

private void upCompanyjobtype(JSONObject data) throws JSONException {
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();
    String s = data.toString();/*from  w w w. j av  a2s.co  m*/
    JCompanyjobtype en = gson.fromJson(s, new TypeToken<JCompanyjobtype>() {
    }.getType());

    String ptime = TextUtility.formatDate(new Date());
    en.setPtime(ptime);
    boolean b = companyjobtypeService.updateJCompanyjobtype(en);
    Map<String, Object> map = new HashMap<String, Object>();
    int status = 1;
    if (b) {
        status = 0;
    } else {
        status = 1;
    }
    map.put("ret", status);
    map.put("msg", "");
    try {
        ResultUtils.toJson(ServletActionContext.getResponse(), map);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.jobchat.action.MobileAction.java

private void addCompanywelfaretype(JSONObject data) throws JSONException {
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();
    String s = data.toString();/*from  www. j a va2  s .co m*/
    JCompanywelfaretype en = gson.fromJson(s, new TypeToken<JCompanywelfaretype>() {
    }.getType());
    en.setStatus((short) 0);
    String ptime = TextUtility.formatDate(new Date());
    en.setPtime(ptime);
    boolean b = companywelfaretypeService.addJCompanywelfaretype(en);
    Map<String, Object> map = new HashMap<String, Object>();
    int status = 1;
    if (b) {
        status = 0;
        map.put("msg", "");
    } else {
        status = 1;
        map.put("msg", "");
    }
    map.put("ret", status);
    try {
        ResultUtils.toJson(ServletActionContext.getResponse(), map);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.jobchat.action.MobileAction.java

private void upCompanywelfaretype(JSONObject data) throws JSONException {
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.create();
    String s = data.toString();/*w ww. j a v a2s .c o m*/
    JCompanywelfaretype en = gson.fromJson(s, new TypeToken<JCompanywelfaretype>() {
    }.getType());

    String ptime = TextUtility.formatDate(new Date());
    en.setPtime(ptime);
    boolean b = companywelfaretypeService.updateJCompanywelfaretype(en);
    Map<String, Object> map = new HashMap<String, Object>();
    int status = 1;
    if (b) {
        status = 0;
    } else {
        status = 1;
    }
    map.put("ret", status);
    map.put("msg", "");
    try {
        ResultUtils.toJson(ServletActionContext.getResponse(), map);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}