Example usage for org.json.simple JSONObject toString

List of usage examples for org.json.simple JSONObject toString

Introduction

In this page you can find the example usage for org.json.simple JSONObject toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:com.eduardojanuario.comente.controller.ComentarioController.java

@Path("/adiciona")
@Post/*w ww . j a  v a2 s.c om*/
public void adiciona(Comentario comentario) {
    dao.adiciona(comentario);

    JSONObject retorno = new JSONObject();
    retorno.put("retorno", "ok");

    result.use(Results.http()).body(retorno.toString());
}

From source file:com.eduardojanuario.comente.controller.ComentarioController.java

@Path("/exclui")
@Post//from w w w.  j  a v  a  2s .  c o  m
public void exclui(Integer id) {

    Comentario comentario = dao.getComentario(id);
    dao.exclui(comentario);

    JSONObject retorno = new JSONObject();
    retorno.put("retorno", "ok");

    result.use(Results.http()).body(retorno.toString());
}

From source file:mongodbutils.Filehandler.java

private Object getCellValue(Cell cell) {

    switch (cell.getCellType()) {
    case Cell.CELL_TYPE_STRING:
        return cell.getRichStringCellValue().getString();
    case Cell.CELL_TYPE_NUMERIC:
        if (DateUtil.isCellDateFormatted(cell)) {
            Date dt = cell.getDateCellValue();

            JSONObject obj = new JSONObject();
            obj.put("$date", dt.getTime());
            return obj.toString();

            //return "" + cell.getDateCellValue();
        } else {//w  w  w .j  ava2  s .c o  m
            return cell.getNumericCellValue();
        }
    case Cell.CELL_TYPE_BOOLEAN:
        return "" + cell.getBooleanCellValue();
    case Cell.CELL_TYPE_FORMULA:
        return cell.getCellFormula();
    }
    return "";
}

From source file:com.consol.citrus.samples.bakery.service.ReportService.java

/**
 * Gets the status of a very specific item found by its id.
 * @return//w ww .ja va 2 s  . c  om
 */
public String status(String id) {
    JSONObject statusJSon = new JSONObject();
    statusJSon.put("status", produced.contains(id));
    return statusJSon.toString();
}

From source file:cc.sferalabs.libs.telegram.bot.api.types.ReplyMarkup.java

/**
 * /*from   www. j  a va2  s  . c  om*/
 * @param fields
 *            the fields-values pairs
 */
@SuppressWarnings("unchecked")
public ReplyMarkup(Object[]... fields) {
    JSONObject obj = new JSONObject();
    for (Object[] field : fields) {
        if (field[1] != null) {
            obj.put(field[0], field[1]);
        }
    }
    this.jsonString = obj.toString();
}

From source file:com.dubture.twig.core.model.Test.java

@SuppressWarnings("unchecked")
@Override/*from   w w  w  .j a  v a 2 s  .  co  m*/
public String getMetadata() {

    JSONObject data = new JSONObject();
    data.put(PHPCLASS, phpClass);
    data.put(DOC, getDocString());
    data.put(INTERNAL, internalFunction);

    return data.toString();
}

From source file:XBMCmote.java

@Command
public String up() {
    JSONObject request = XBMC.inputUp;

    String response = XBMC.sendCommand(request);

    return String.format("%s\n%s", request.toString(), response);
}

From source file:localworker.LocalWorker.java

@SuppressWarnings("unchecked")
@Override//from w ww  . j  a  va  2s  .c om
public void run() {
    JSONParser parser = new JSONParser();
    JSONObject json;
    String task_id = null;
    String task;

    try {

        while (true) {
            //waiting up to 100ms for an element to become available.
            String messageBody = jobQ.poll(100, TimeUnit.MILLISECONDS);

            if (messageBody != null) {

                json = (JSONObject) parser.parse(messageBody);

                task_id = json.get("task_id").toString();
                task = json.get("task").toString();

                Thread.sleep(Long.parseLong(task));

                JSONObject result = new JSONObject();
                result.put("task_id", task_id);
                result.put("result", "0");
                respQ.put(result.toString());

                //System.out.println(Thread.currentThread().getName()+" sleep done!");
            }
        }

    } catch (Exception e) {
        JSONObject result = new JSONObject();
        result.put("task_id", task_id);
        result.put("result", "1");
        try {
            respQ.put(result.toString());

        } catch (InterruptedException e1) {
            e1.printStackTrace();
        }
    }
}

From source file:XBMCmote.java

@Command
public String down() {
    JSONObject request = XBMC.inputDown;

    String response = XBMC.sendCommand(request);

    return String.format("%s\n%s", request.toString(), response);
}

From source file:XBMCmote.java

@Command
public String left() {
    JSONObject request = XBMC.inputLeft;

    String response = XBMC.sendCommand(request);

    return String.format("%s\n%s", request.toString(), response);
}