Example usage for com.google.gson JsonObject add

List of usage examples for com.google.gson JsonObject add

Introduction

In this page you can find the example usage for com.google.gson JsonObject add.

Prototype

public void add(String property, JsonElement value) 

Source Link

Document

Adds a member, which is a name-value pair, to self.

Usage

From source file:userDAO.java

@GET
@Path("/login")
@Produces("application/json")
public String loginUser(@QueryParam("email") String email, @QueryParam("password") String password) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    Query query = entityManager.createNamedQuery("User.findByEmail").setParameter("email", email);
    List<User> users = query.getResultList();
    JsonObject jsonObject = new JsonObject();
    if (users.size() == 0) {
        jsonObject.addProperty("status", "FAILED");
        jsonObject.addProperty("result", "Sorry! This Email is not registered on ContactO!");
    } else {/*from  w ww  .  j  a  v a 2 s  .co  m*/
        Query query2 = entityManager.createNamedQuery("User.findByEmailandPassword")
                .setParameter("email", email).setParameter("password", password);
        List<User> userss = query2.getResultList();
        if (userss.size() == 0) {
            jsonObject.addProperty("status", "FAILED");
            jsonObject.addProperty("result", "Sorry! Wrong Password!");
        } else {
            jsonObject.addProperty("status", "SUCCESS");
            Gson gson = new Gson();
            //                JsonArray jsonArray=new JsonArray();
            //                for (User user : userss) {
            //               
            //                    jsonArray.add(JsonObj);
            //                }
            jsonObject.add("result", getAllcontacts(email));
        }
    }
    return new Gson().toJson(jsonObject);
}

From source file:JavaTestRunner.java

License:Apache License

private static JsonObject mkConstants(JsonElement input, ZonedDateTime now) {
    JsonObject jsonObject = new JsonObject();
    jsonObject.add("CONST$WORLD", input);
    jsonObject.addProperty("CONST$NOW", now.toString());
    return jsonObject;
}

From source file:ListAction.java

@Override
public void execute(HttpServletRequest request, PrintWriter out, File folder) {

    try {//from w  w  w . java  2 s  .  c o m
        String type = request.getParameter("type");

        JsonArray list = new JsonArray();

        switch (type) {
        case "movie":
            File[] movies = Service.listAllMovies(folder);

            for (int i = 0; i < movies.length; i++) {
                JsonObject m = new JsonObject();
                m.addProperty("title", movies[i].getName());
                list.add(m);
            }

            break;

        case "series":
            File[] series = Service.listAllSeries(folder);

            for (int i = 0; i < series.length; i++) {
                JsonObject m = new JsonObject();
                m.addProperty("title", series[i].getName());
                list.add(m);
            }

            break;

        case "episode":
            String series_title = request.getParameter("series");

            folder = new File(folder.getAbsolutePath() + "\\Series\\" + series_title);

            List<File> episodes = Service.listAllEpisodes(folder);

            for (File f : episodes) {
                JsonObject episode = new JsonObject();

                String title = f.getName().split(" - ")[0];

                episode.addProperty("title", series_title + " - " + title);

                list.add(episode);
            }

            break;
        }

        JsonObject container = new JsonObject();

        container.add("list", list);

        Gson gson = new GsonBuilder().setPrettyPrinting().create();
        String json = gson.toJson(container);
        out.println(json);
    } catch (Exception e) {
        throw e;
    }
}

From source file:EAIJSONConverter.java

License:Open Source License

public static SiebelPropertySet JsonObjectToPropertySet(JsonObject obj, SiebelPropertySet ps) {
    Iterator<Entry<String, JsonElement>> iterator = obj.entrySet().iterator();
    SiebelPropertySet child;//from w ww  . j  a v  a  2  s  . c  o m
    while (iterator.hasNext()) {
        JsonArray jsonArray = new JsonArray();
        JsonObject jsonObject = new JsonObject();
        Map.Entry mapEntry = (Map.Entry) iterator.next();
        if (mapEntry != null) {
            JsonElement jsonelement = (JsonElement) mapEntry.getValue();
            if (jsonelement.isJsonArray()) {
                jsonArray = jsonelement.getAsJsonArray();
                child = new SiebelPropertySet();
                child.setType("ListOf-" + mapEntry.getKey().toString());
                for (int i = 0; i < jsonArray.size(); i++) {
                    if (jsonArray.get(i).isJsonObject() || jsonArray.get(i).isJsonArray()) {
                        SiebelPropertySet temp = new SiebelPropertySet();
                        temp.setType("" + i);
                        if (jsonArray.get(i).isJsonObject())
                            child.addChild(JsonObjectToPropertySet(jsonArray.get(i).getAsJsonObject(), temp));
                        else {
                            JsonObject aux = new JsonObject();
                            aux.add("" + i, jsonArray.get(i));
                            child.addChild(JsonObjectToPropertySet(aux, temp));

                        }
                    } else
                        child.setProperty("" + i, jsonArray.get(i).getAsString());
                }
                ps.addChild(child);
            } else if (jsonelement.isJsonObject()) {
                jsonObject = jsonelement.getAsJsonObject();
                child = new SiebelPropertySet();
                child.setType(mapEntry.getKey().toString());
                ps.addChild(JsonObjectToPropertySet(jsonObject, child));
            } else {
                ps.setProperty(mapEntry.getKey().toString(), mapEntry.getValue().toString());
            }
        }
    }

    return ps;
}

From source file:EAIJSONConverter.java

License:Open Source License

public JsonObject traversePS(SiebelPropertySet ps, JsonObject jObj) {
    JsonObject siebJSON = new JsonObject();
    String propName;//  ww  w. jav  a2  s.c  om
    String propVal;
    propName = ps.getFirstProperty();

    while (propName != "") {
        propVal = ps.getProperty(propName);
        siebJSON.addProperty(propName, propVal);
        propName = ps.getNextProperty();
    }

    JsonObject child;

    for (int i = 0; i < ps.getChildCount(); i++) {
        child = new JsonObject();

        if (ps.getChild(i).getType().startsWith("ListOf-"))

        {
            JsonArray ja = new JsonArray();
            for (int o = 0; o < ps.getChild(i).getChildCount(); o++) {
                ja.add(traversePS(ps.getChild(i).getChild(o), child));
            }
            siebJSON.add(ps.getChild(i).getType().substring(7), ja);
        } else if (ps.getChild(i).getType().startsWith("StringList-"))

        {
            JsonArray ja = new JsonArray();
            SiebelPropertySet auxps = ps.getChild(i);
            Enumeration e = auxps.getPropertyNames();
            List list = Collections.list(e);
            Collections.sort(list);
            e = Collections.enumeration(list);

            while (e.hasMoreElements()) {
                String propName1 = (String) e.nextElement();
                ja.add(new JsonPrimitive(auxps.getProperty(propName1)));
            }
            siebJSON.add(auxps.getType().substring(11), ja);
        } else {
            child = traversePS(ps.getChild(i), child);
            siebJSON.add(ps.getChild(i).getType(), child);
        }
    }

    return siebJSON;
}

From source file:CustomAudienceExample.java

License:Open Source License

public static void main(String[] args) {
    try {//www. j  a  va2s . co  m
        AdAccount account = new AdAccount(ACCOUNT_ID, context);

        CustomAudience audience = account.createCustomAudience().setName("Java SDK Test Custom Audience")
                .setDescription("Test Audience").setSubtype(EnumSubtype.VALUE_CUSTOM).execute();

        // Audience payload schema
        JsonArray schema = new JsonArray();
        schema.add(new JsonPrimitive("EMAIL_SHA256"));
        schema.add(new JsonPrimitive("PHONE_SHA256"));

        // Audience payload data
        JsonArray personA = new JsonArray();
        personA.add(new JsonPrimitive(sha256("aaa@example.com")));
        personA.add(new JsonPrimitive(sha256("1234567890")));
        JsonArray personB = new JsonArray();
        personB.add(new JsonPrimitive(sha256("bbb@example.com")));
        personB.add(new JsonPrimitive(sha256("1234567890")));
        JsonArray personC = new JsonArray();
        personC.add(new JsonPrimitive(sha256("ccc@example.com")));
        personC.add(new JsonPrimitive(sha256("1234567890")));

        JsonArray data = new JsonArray();
        data.add(personA);
        data.add(personB);
        data.add(personC);

        JsonObject payload = new JsonObject();
        payload.add("schema", schema);
        payload.add("data", data);

        audience.createUser().setPayload(payload.toString()).execute();

        System.out.println(audience.fetch());

        Targeting targeting = new Targeting().setFieldCustomAudiences("[{id:" + audience.getId() + "}]");

        Campaign campaign = account.createCampaign().setName("Java SDK Test Campaign")
                .setObjective(Campaign.EnumObjective.VALUE_LINK_CLICKS).setSpendCap(10000L)
                .setStatus(Campaign.EnumStatus.VALUE_PAUSED).execute();
        AdSet adset = account.createAdSet().setName("Java SDK Test AdSet").setCampaignId(campaign.getFieldId())
                .setStatus(AdSet.EnumStatus.VALUE_PAUSED)
                .setBillingEvent(AdSet.EnumBillingEvent.VALUE_IMPRESSIONS).setDailyBudget(1000L)
                .setBidAmount(100L).setOptimizationGoal(AdSet.EnumOptimizationGoal.VALUE_IMPRESSIONS)
                .setTargeting(targeting).setRedownload(true).requestAllFields().execute();
        System.out.println(adset);
        AdImage image = account.createAdImage().addUploadFile("file", imageFile).execute();
        AdCreative creative = account.createAdCreative().setTitle("Java SDK Test Creative")
                .setBody("Java SDK Test Creative").setImageHash(image.getFieldHash())
                .setLinkUrl("www.facebook.com").setObjectUrl("www.facebook.com").execute();
        Ad ad = account.createAd().setName("Java SDK Test ad").setAdsetId(Long.parseLong(adset.getId()))
                .setCreative(creative).setStatus("PAUSED").setBidAmount(100L).setRedownload(true).execute();
    } catch (APIException e) {
        e.printStackTrace();
    }
}

From source file:account.BajajReport.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*  ww  w . j av  a 2 s.  com*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    final String from_date = request.getParameter("from_date");
    final String to_date = request.getParameter("to_date");
    final String ac_cd = request.getParameter("ac_cd");
    final int branch_cd = Integer.parseInt(request.getParameter("branch_cd"));
    final DBHelper helper = DBHelper.GetDBHelper();
    final Connection dataConnection = helper.getConnMpAdmin();
    final JsonObject jResultObj = new JsonObject();
    final Library lb = Library.getInstance();
    if (dataConnection != null) {
        try {
            String sql = "select v1.v_type,v1.branch_cd,v.ref_no,v1.inv_no,a.FNAME,s.SR_NAME,v1.V_DATE as ins_date,v.TAG_NO,p.BAJAJ_AMT,p.SFID,a1.fname as bajaj_name from vilsdt v "
                    + " left join SERIESMST s on v.SR_CD=s.SR_CD left join VILSHD v1 on v.REF_NO=v1.REF_NO left join acntmst a on v1.AC_CD=a.AC_CD "
                    + " left join payment p on v1.ref_no=p.ref_no left join acntmst a1 on p.bajaj_name=a1.ac_cd "
                    + " where v1.V_DATE>='" + from_date + "'" + " and v1.V_DATE<='" + to_date
                    + "' and v1.is_del=0 and p.bajaj_amt <>0 "
                    + " and (v.IMEI_NO<>'' or v.SERAIL_NO<>'') and v.is_main=1";
            if (branch_cd != 0) {
                sql += " and v1.branch_cd=" + branch_cd;
            }
            if (!ac_cd.equalsIgnoreCase("")) {
                sql += " and p.bajaj_name='" + ac_cd + "'";
            }
            sql += " order by v1.V_DATE";
            PreparedStatement pstLocal = dataConnection.prepareStatement(sql);
            ResultSet viewDataRs = pstLocal.executeQuery();

            JsonArray array = new JsonArray();
            while (viewDataRs.next()) {
                JsonObject object = new JsonObject();
                object.addProperty("INV_NO", viewDataRs.getString("INV_NO"));
                object.addProperty("V_TYPE", viewDataRs.getString("V_TYPE"));
                object.addProperty("FNAME", viewDataRs.getString("FNAME"));
                object.addProperty("SR_NAME", viewDataRs.getString("SR_NAME"));
                object.addProperty("TAG_NO", viewDataRs.getString("TAG_NO"));
                object.addProperty("INS_DATE", viewDataRs.getString("ins_date"));
                object.addProperty("branch_cd", viewDataRs.getString("branch_cd"));
                object.addProperty("RATE", viewDataRs.getDouble("BAJAJ_AMT"));
                object.addProperty("REF_NO", viewDataRs.getString("REF_NO"));
                object.addProperty("SFID", viewDataRs.getString("SFID"));
                object.addProperty("BAJAJ_NAME", viewDataRs.getString("BAJAJ_NAME"));
                array.add(object);
            }
            lb.closeResultSet(viewDataRs);
            lb.closeStatement(pstLocal);
            jResultObj.addProperty("result", 1);
            jResultObj.addProperty("Cause", "success");
            jResultObj.add("data", array);
        } catch (SQLNonTransientConnectionException ex1) {
            jResultObj.addProperty("result", -1);
            jResultObj.addProperty("Cause", "Server is down");
        } catch (SQLException ex) {
            jResultObj.addProperty("result", -1);
            jResultObj.addProperty("Cause", ex.getMessage());
        } finally {
            lb.closeConnection(dataConnection);
        }
    }
    response.getWriter().print(jResultObj);
}

From source file:account.BankBook.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*from  www . j a  v  a2s. c  o  m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    DBHelper helper = DBHelper.GetDBHelper();
    dataConnection = helper.getConnMpAdmin();
    final JsonObject jResultObj = new JsonObject();
    ac_cd = request.getParameter("ac_cd");
    rec_date = Boolean.parseBoolean(request.getParameter("rec_date"));
    from_date = request.getParameter("from_date");
    to_date = request.getParameter("to_date");
    try {
        if (dataConnection != null) {
            makeQuery();
            double opbRs = 0.00;
            JsonArray array = new JsonArray();
            while (viewDataRS.next()) {
                JsonObject object = new JsonObject();
                object.addProperty("DOC_REF_NO", viewDataRS.getString("INV_NO"));
                object.addProperty("DOC_DATE", viewDataRS.getString("DOC_DATE"));
                object.addProperty("REC_DATE", viewDataRS.getString("REC_DATE"));
                object.addProperty("DOC_CD", viewDataRS.getString("DOC_CD"));
                object.addProperty("DR", viewDataRS.getDouble("DR"));
                object.addProperty("CR", viewDataRS.getDouble("CR"));
                opbRs += viewDataRS.getDouble("DR") - viewDataRS.getDouble("CR");
                object.addProperty("BAL", opbRs);
                object.addProperty("PARTICULAR", viewDataRS.getString("PARTICULAR"));
                object.addProperty("OPP_AC_CD", viewDataRS.getString("OPP_AC_CD"));
                object.addProperty("REC_DATE", viewDataRS.getString("REC_DATE"));
                object.addProperty("OPP_NAME", viewDataRS.getString("OPP_NAME"));
                object.addProperty("REF_NO", viewDataRS.getString("doc_ref_no"));
                object.addProperty("CHQ_NO", viewDataRS.getString("CHQ_NO"));
                object.addProperty("REC_BANK_NAME", viewDataRS.getString("REC_BANK_NAME"));
                array.add(object);
            }

            String sql = "(select (select case when sum(val) is null then 0 else sum(val)end  from OLDB2_2 where AC_CD='"
                    + ac_cd + "' and ((doc_date <'" + from_date + "') and (REC_DATE <'" + from_date
                    + "')) and CRDR=0) -"
                    + "(select case when sum(val) is null then 0 else sum(val)end  from OLDB2_2 where AC_CD='"
                    + ac_cd + "' " + "and ((doc_date <'" + from_date + "') and (REC_DATE <'" + from_date
                    + "')) and CRDR=1)  as opb from dual) ";
            PreparedStatement pstLocal = dataConnection.prepareStatement(sql);
            viewDataRS = pstLocal.executeQuery();
            if (viewDataRS.next()) {
                jResultObj.addProperty("opb", viewDataRS.getDouble("opb"));
            } else {
                jResultObj.addProperty("opb", 0.00);
            }
            jResultObj.addProperty("result", 1);
            jResultObj.addProperty("Cause", "success");
            jResultObj.add("data", array);
        }
    } catch (SQLNonTransientConnectionException ex1) {
        jResultObj.addProperty("result", -1);
        jResultObj.addProperty("Cause", "Server is down");
    } catch (SQLException ex) {
        jResultObj.addProperty("result", -1);
        jResultObj.addProperty("Cause", ex.getMessage());
    }
    response.getWriter().print(jResultObj);
}

From source file:account.BranchWisePendingCollecionReport.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*w  w w  . j ava 2 s. c om*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    final DBHelper helper = DBHelper.GetDBHelper();
    final Connection dataConnection = helper.getConnMpAdmin();
    final JsonObject jResultObj = new JsonObject();
    final int branch_cd = Integer.parseInt(request.getParameter("branch_cd"));
    final int v_type = Integer.parseInt(request.getParameter("v_type"));
    final String ref_cd = (request.getParameter("ref_cd"));
    final Library lb = Library.getInstance();
    if (dataConnection != null) {
        try {

            PreparedStatement pstLocal = null;
            String sql = "SELECT p.mobile1,v.REMARK,v.INV_NO,o.DOC_REF_NO,o.DOC_DATE,o.AC_CD,o.UNPAID_AMT,o.DUE_DATE,v.BRANCH_CD,a.FNAME,v.buy_back_model,v.buy_back_amt,r.ref_name FROM "
                    + "oldb2_4 o LEFT JOIN vilshd v ON v.REF_NO=o.DOC_REF_NO LEFT JOIN acntmst a ON a.AC_CD=v.AC_CD "
                    + " left join refmst r on v.ref_cd=r.ref_cd left join phbkmst p on a.ac_cd=p.ac_cd"
                    + " WHERE doc_ref_no LIKE '02%' AND o.UNPAID_AMT >0 and v.is_del=0 ";
            if (branch_cd != 0) {
                sql += " and v.branch_cd=" + branch_cd;
            }
            if (v_type != -1) {
                sql += " and v.v_type=" + v_type;
            }
            if (!ref_cd.equalsIgnoreCase("0")) {
                sql += " and v.REF_CD='" + ref_cd + "'";
            }
            pstLocal = dataConnection.prepareStatement(sql);
            ResultSet viewDataRs = pstLocal.executeQuery();

            JsonArray array = new JsonArray();
            while (viewDataRs.next()) {
                JsonObject object = new JsonObject();
                object.addProperty("DOC_DATE", viewDataRs.getString("DOC_DATE"));
                object.addProperty("INV_NO", viewDataRs.getString("INV_NO"));
                object.addProperty("DOC_REF_NO", viewDataRs.getString("DOC_REF_NO"));
                object.addProperty("AC_CD", viewDataRs.getString("AC_CD"));
                object.addProperty("DOC_CD", "");
                object.addProperty("UNPAID_AMT", viewDataRs.getDouble("UNPAID_AMT"));
                object.addProperty("DUE_DATE", viewDataRs.getString("DUE_DATE"));
                object.addProperty("branch_cd", viewDataRs.getString("branch_cd"));
                object.addProperty("FNAME", viewDataRs.getString("FNAME"));
                object.addProperty("BUY_BACK_MODEL", viewDataRs.getString("BUY_BACK_MODEL"));
                object.addProperty("BUY_BACK_AMT", viewDataRs.getString("BUY_BACK_AMT"));
                object.addProperty("REMARK", viewDataRs.getString("REMARK"));
                object.addProperty("MOBILE1",
                        (viewDataRs.getString("MOBILE1") == null) ? "" : viewDataRs.getString("MOBILE1"));
                object.addProperty("REF_NAME",
                        (viewDataRs.getString("REF_NAME") == null) ? "" : viewDataRs.getString("REF_NAME"));
                array.add(object);
            }
            lb.closeResultSet(viewDataRs);
            lb.closeStatement(pstLocal);
            jResultObj.addProperty("result", 1);
            jResultObj.addProperty("Cause", "success");
            jResultObj.add("data", array);
        } catch (SQLNonTransientConnectionException ex1) {
            jResultObj.addProperty("result", -1);
            jResultObj.addProperty("Cause", "Server is down");
        } catch (SQLException ex) {
            jResultObj.addProperty("result", -1);
            jResultObj.addProperty("Cause", ex.getMessage());
        } finally {
            lb.closeConnection(dataConnection);
        }
    }
    response.getWriter().print(jResultObj);
}

From source file:account.BuyBackRegister.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*from ww  w.  j a v  a2 s  .com*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    final String from_date = request.getParameter("from_date");
    final String to_date = request.getParameter("to_date");
    final String ac_cd = request.getParameter("ac_cd");
    final DBHelper helper = DBHelper.GetDBHelper();
    final Connection dataConnection = helper.getConnMpAdmin();
    final JsonObject jResultObj = new JsonObject();
    final String sr_cd = request.getParameter("sr_cd");
    final String type_cd = request.getParameter("type_cd");
    final String brand_cd = request.getParameter("brnad_cd");
    final String model_cd = request.getParameter("model_cd");
    if (dataConnection != null) {
        try {

            PreparedStatement pstLocal = null;
            String sql = "select v.branch_cd,v.inv_no,v.ref_no,a.fname,v.BUY_BACK_MODEL,v.v_date,'' as TYPE_NAME,BUY_BACK_MODEL as IMEI_NO,BUY_BACK_IMEI_NO,(1) as pcs,BUY_BACK_AMT as tot_sales from VILSHD v  "
                    + " left join acntmst a on v.ac_cd=a.ac_cd where v.IS_DEL=0 " + " and v.v_date>='"
                    + from_date + "' " + " and v.v_date<='" + to_date + "'   and v.BUY_BACK_AMT <> 0";
            if (!type_cd.equalsIgnoreCase("")) {
                sql += " and m.type_cd='" + type_cd + "' ";
            }
            if (!sr_cd.equalsIgnoreCase("")) {
                sql += " and s.SR_CD='" + sr_cd + "'";
            } else if (!brand_cd.equalsIgnoreCase("")) {
                sql += " and s.brand_cd='" + brand_cd + "'";
            } else if (!model_cd.equalsIgnoreCase("")) {
                sql += " and s.model_cd='" + model_cd + "'";
            }
            if (!ac_cd.equalsIgnoreCase("")) {
                sql += " and v.ac_cd='" + ac_cd + "'";
            }

            pstLocal = dataConnection.prepareStatement(sql);
            ResultSet viewDataRs = pstLocal.executeQuery();

            JsonArray array = new JsonArray();
            while (viewDataRs.next()) {
                JsonObject object = new JsonObject();
                object.addProperty("fname", viewDataRs.getString("fname"));
                object.addProperty("sr_name", viewDataRs.getString("BUY_BACK_MODEL"));
                object.addProperty("v_date", viewDataRs.getString("v_date"));
                object.addProperty("type_name", viewDataRs.getString("type_name"));
                object.addProperty("pcs", viewDataRs.getInt("pcs"));
                object.addProperty("tot_sales", viewDataRs.getDouble("tot_sales"));
                object.addProperty("IMEI_NO", viewDataRs.getString("IMEI_NO"));
                object.addProperty("BUY_BACK_IMEI_NO", viewDataRs.getString("BUY_BACK_IMEI_NO"));
                object.addProperty("REF_NO", viewDataRs.getString("REF_NO"));
                object.addProperty("INV_NO", viewDataRs.getString("INV_NO"));
                object.addProperty("branch_cd", viewDataRs.getString("branch_cd"));
                array.add(object);
            }

            jResultObj.addProperty("result", 1);
            jResultObj.addProperty("Cause", "success");
            jResultObj.add("data", array);
        } catch (SQLNonTransientConnectionException ex1) {
            jResultObj.addProperty("result", -1);
            jResultObj.addProperty("Cause", "Server is down");
        } catch (SQLException ex) {
            jResultObj.addProperty("result", -1);
            jResultObj.addProperty("Cause", ex.getMessage());
        }
    }
    response.getWriter().print(jResultObj);

}