Example usage for org.json.simple JSONObject put

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

Introduction

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

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:com.echonest.api.v4.Biography.java

public JSONObject toJSON() {
    JSONObject jo = new JSONObject();
    jo.put("site", this.getSite());
    jo.put("text", this.getText());
    jo.put("url", this.getURL());

    JSONObject li = new JSONObject();
    li.put("type", this.getLicenseType());
    li.put("attribution", this.getLicenseAttribution());

    jo.put("license", li);

    return jo;//from   www  . j  a  v a2  s.com
}

From source file:at.uni_salzburg.cs.ckgroup.cscpp.mapper.course.WayPoint.java

@SuppressWarnings("unchecked")
@Override/* w  w  w  .j  a  v a  2 s .c  om*/
public String toJSONString() {
    JSONObject obj = new JSONObject();
    obj.put("latitude", Double.valueOf(point.getLatitude()));
    obj.put("longitude", Double.valueOf(point.getLongitude()));
    obj.put("altitude", Double.valueOf(point.getAltitude()));
    obj.put("precision", Double.valueOf(precision));
    obj.put("velocity", Double.valueOf(velocity));
    return obj.toString();
}

From source file:com.imagelake.android.category.Servlet_categories.java

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

    PrintWriter out = response.getWriter();

    CategoriesDAOImp categoryDAOImp = new CategoriesDAOImp();
    JSONArray ja = new JSONArray();
    ArrayList<Categories> categoriesList = (ArrayList<Categories>) categoryDAOImp.listAllCategories();
    if (!categoriesList.isEmpty()) {
        for (Categories cc : categoriesList) {
            JSONObject jo = new JSONObject();
            jo.put("id", cc.getCategory_id());
            jo.put("cat", cc.getCategory());
            ja.add(jo);//w ww .  j a  va2s .  c o m

        }
        out.write("json=" + ja.toJSONString());
    } else {

        JSONObject jo = new JSONObject();
        jo.put("id", 0);
        jo.put("cat", "No category found.");
        ja.add(jo);
        out.write("json=" + ja.toJSONString());

    }
}

From source file:com.mobicage.rogerthat.FlowCallbackResult.java

@SuppressWarnings("unchecked")
@Override/*from   ww  w.ja v a2 s . co m*/
public JSONObject toJSONObject() {
    final JSONObject result = new JSONObject();
    result.put("flow", flow);
    result.put("tag", tag);
    return result;
}

From source file:halive.shootinoutside.common.util.Vector2D.java

public JSONObject toJSONObject() {
    JSONObject obj = new JSONObject();
    obj.put("x", Float.floatToIntBits(x));
    obj.put("y", Float.floatToIntBits(y));
    return obj;/* w w w. j a v a2s.  com*/
}

From source file:com.au.splashinc.JControl.Load.JsonLoader.java

protected JSONObject GetJSONObject(Object key, Object value) {
    JSONObject jo = new JSONObject();
    jo.put(key, value);
    return jo;//from  www .j  av a2 s .  co m
}

From source file:com.oic.event.map.GetMapUserList.java

@Override
public void ActionEvent(JSONObject json, WebSocketListener webSocket) {
    JSONObject responseJSON = new JSONObject();
    responseJSON.put("method", "getmapuserlist");
    if (!validation(json)) {
        responseJSON.put("status", 1);
        webSocket.sendJson(responseJSON);
        return;//from  ww w . j av  a  2s . c o  m
    }

    int mapid = Integer.parseInt(json.get("mapid").toString());
    MapFactory factory = MapFactory.getInstance();
    OicMap map = factory.getMap(mapid);
    JSONArray charactersJSON = new JSONArray();
    try {
        for (Long userid : map.getUserIdList()) {
            charactersJSON.add(userid);
        }
    } catch (NullPointerException ex) {
    }

    responseJSON.put("userlist", charactersJSON);
    webSocket.sendJson(responseJSON);
}

From source file:cpd3314.buildit12.Car.java

public JSONObject toJSON() {
    JSONObject json = new JSONObject();
    json.put("make", make);
    json.put("model", model);
    json.put("year", year);
    return json;/* ww  w  .j  a va 2 s . com*/
}

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

@SuppressWarnings("unchecked")
@Override//from w w  w.  j ava  2s.c o  m
public HttpEntity createDocument(Property property) {

    JSONObject propertyObject = new JSONObject();
    propertyObject.put("title", property.getTitle());
    propertyObject.put("value", property.getValue());
    String creationDate = property.getCreationDate() != null ? formatDate(property.getCreationDate()) : null;
    propertyObject.put("creationDate", creationDate);
    propertyObject.put("processes", addObjectRelation(property.getProcesses()));
    propertyObject.put("templates", addObjectRelation(property.getTemplates()));
    propertyObject.put("workpieces", addObjectRelation(property.getWorkpieces()));

    String type = null;
    if (!property.getProcesses().isEmpty()) {
        type = "process";
    } else if (!property.getTemplates().isEmpty()) {
        type = "template";
    } else if (!property.getWorkpieces().isEmpty()) {
        type = "workpiece";
    }

    propertyObject.put("type", type);

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

From source file:com.mobicage.rogerthat.form.Choice.java

@Override
@SuppressWarnings("unchecked")
public JSONObject toJSONObject() {
    JSONObject result = new JSONObject();
    result.put("label", label);
    result.put("value", value);
    return result;
}