Example usage for org.json.simple JSONObject toJSONString

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

Introduction

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

Prototype

public String toJSONString() 

Source Link

Usage

From source file:at.uni_salzburg.cs.ckgroup.cscpp.engine.actions.Random.java

@SuppressWarnings("unchecked")
@Override//from w  w  w . j  a  v a2s  .c  o  m
public String toJSONString() {
    JSONObject o = new JSONObject();
    o.put("type", ISensorProxy.SENSOR_NAME_RANDOM);
    if (getTimestamp() != 0) {
        o.put("time", getTimestamp());
        o.put("value", random);
    }
    return o.toJSONString();
}

From source file:org.kitodo.data.elasticsearch.index.type.FilterType.java

@SuppressWarnings("unchecked")
@Override//from   w w  w. j  av a2 s. c om
public HttpEntity createDocument(Filter filter) {

    JSONObject propertyObject = new JSONObject();
    propertyObject.put("value", filter.getValue());
    Integer user = filter.getUser() != null ? filter.getUser().getId() : null;
    propertyObject.put("user", user);

    return new NStringEntity(propertyObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:naftoreiclag.villagefive.world.plot.Plot.java

public String toJSONString() {
    JSONObject obj = new JSONObject();

    obj.put("location", loc);
    obj.put("blueprint", blueprint);

    return obj.toJSONString();
}

From source file:Assignment4.Product.java

public String toJSON() {
    JSONObject obj = new JSONObject();

    obj.put("productId", this.id);
    obj.put("productname", this.name);
    obj.put("description", this.description);
    obj.put("quantity", this.quantity);

    return obj.toJSONString();
}

From source file:at.uni_salzburg.cs.ckgroup.cscpp.engine.actions.Temperature.java

@SuppressWarnings("unchecked")
@Override//  www. j a v  a  2 s.c o m
public String toJSONString() {
    JSONObject o = new JSONObject();
    o.put("type", ISensorProxy.SENSOR_NAME_TEMPERATURE);
    if (getTimestamp() != 0) {
        o.put("time", getTimestamp());
        o.put("value", temperature);
    }
    return o.toJSONString();
}

From source file:at.uni_salzburg.cs.ckgroup.cscpp.engine.actions.AirPressure.java

@SuppressWarnings("unchecked")
@Override//  w ww  .  j  a v  a2 s. c o m
public String toJSONString() {
    JSONObject o = new JSONObject();
    o.put("type", ISensorProxy.SENSOR_NAME_AIR_PRESSURE);
    if (getTimestamp() != 0) {
        o.put("time", getTimestamp());
        o.put("value", airPressure);
    }
    return o.toJSONString();
}

From source file:com.aerothai.database.building.BuildingResource.java

/**
 * Retrieves representation of an instance of com.aerothai.BuildingResource
 * @return an instance of java.lang.String
 *//*from w w  w.j  a  va 2  s .  c o m*/
@GET
@Produces("application/json")
public String listBuildingAt(@PathParam("id") int id) {
    String response = null;

    System.out.println("List Building At ID");
    try {
        JSONObject buildingData = null;
        BuildingService buildingService = new BuildingService();
        buildingData = buildingService.GetBuildingAt(id);

        response = buildingData.toJSONString();
    } catch (Exception e) {
        System.out.println("error");
    }

    return response;
}

From source file:com.conwet.xjsp.features.MessageChannel.java

@SuppressWarnings("unchecked")
synchronized public void sendErrorMessage(Object payload) throws IOException {
    JSONObject message = new JSONObject();
    message.put("id", nextId());
    message.put("type", XJSPConstants.XJSP_PREFIX + ":error");
    message.put("message", payload);
    sendFragment(message.toJSONString());
}

From source file:com.des.paperbase.ManageData.java

public void delete(String Tablename, Map<String, Object> value, String FilterType)
        throws ParseException, IOException {
    String data = g.readFileToString(PATH_FILE + "\\" + Tablename + ".json");
    List<Integer> ListDelete = new LinkedList<Integer>();
    if (!data.equalsIgnoreCase("{\"data\":[]}")) {
        JSONObject json = (JSONObject) new JSONParser().parse(data);
        JSONArray OldValue = (JSONArray) json.get("data");
        for (int s = 0; s < OldValue.size(); s++) {
            JSONObject record = (JSONObject) OldValue.get(s);
            if (MappingRecordAndKey(value, record, FilterType)) {
                ListDelete.add(s);/*from ww w  . j  a  v a 2 s  . c  o m*/
            }
        }
        for (int i = ListDelete.size() - 1; i >= 0; i--) {
            System.out.print(ListDelete.get(i) + " ");
            OldValue.remove(ListDelete.get(i).intValue());
        }
        JSONObject table = new JSONObject();
        table.put("data", OldValue);
        g.writefile(table.toJSONString(), PATH_FILE + "\\" + Tablename + ".json");
    }

}

From source file:com.aerothai.database.position.PositionResource.java

/**
 * Retrieves representation of an instance of com.aerothai.PositionResource
 * @return an instance of java.lang.String
 *///from w  w w . jav  a  2  s.c o m
@GET
@Produces("application/json")
public String listPositionAt(@PathParam("id") int id) {
    String response = null;

    System.out.println("List Position At ID");
    try {
        JSONObject positionData = null;
        PositionService positionService = new PositionService();
        positionData = positionService.GetPositionAt(id);

        response = positionData.toJSONString();
    } catch (Exception e) {
        System.out.println("error");
    }

    return response;
}