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:modelo.UsuariosManagers.Roles.java

public JSONArray getRoles(String usuario, String rol, String codigo) throws SQLException {

    SeleccionarRoles select = new SeleccionarRoles();

    ResultSet rset = select.getRoles(codigo, usuario);

    //Creamos los JSONArray para guardar los objetos JSON
    JSONArray jsonArray = new JSONArray();
    JSONArray jsonArreglo = new JSONArray();
    //Recorremos el ResultSet, armamos el objeto JSON con la info y guardamos en el JSONArray.
    while (rset.next()) {
        //Armamos el objeto JSON con la informacion del registro
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("codigo", rset.getString("PK_CODIGO"));
        jsonObject.put("descripcion", rset.getString("VAR_ROL"));
        //Guardamos el JSONObject en el JSONArray y lo enviamos a la vista.
        jsonArray.add(jsonObject.clone());
    }// w w  w  .jav  a  2 s  .  c o m

    select.desconectar();
    jsonArreglo.add(jsonArray);
    return jsonArreglo;

}

From source file:MyMemoryListener.java

@SuppressWarnings("unchecked")
public void nativeMemoryEvent(NativeMemoryEvent event) {
    obj.put("timestamp", event.getEventTime());
    JSONObject processMem = new JSONObject();
    processMem.put("private", event.getProcessPrivate());
    processMem.put("physical", event.getProcessPhysical());
    processMem.put("virtual", event.getProcessVirtual());

    JSONObject systemMem = new JSONObject();
    systemMem.put("physical", event.getFreePhysicalMemory());
    systemMem.put("total", event.getTotalPhysicalMemory());

    JSONObject mem = new JSONObject();
    mem.put("process", processMem);
    mem.put("system", systemMem);
    obj.put("memory", mem);

    IndexResponse response = eSC.getClient().prepareIndex(eSC.getIndex(), "memory")
            .setSource(obj.toJSONString()).get();
}

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

@Override
public void ActionEvent(JSONObject json, WebSocketListener webSocket) {
    JSONObject responseJSON = new JSONObject();
    responseJSON.put("method", "transfermap");
    if (!validation(json)) {
        responseJSON.put("status", "1");
        webSocket.sendJson(responseJSON);
        return;/*from   w ww  .j  a  v a  2  s.co m*/
    }
    int oldMapid = webSocket.getCharacter().getMapid();
    int mapid = Integer.parseInt(json.get("mapid").toString());
    OicCharacter c = webSocket.getCharacter();
    c.changeMap(mapid);
    responseJSON.put("mapid", mapid);
    responseJSON.put("status", 0);
    webSocket.sendJson(responseJSON);

    //
    new PosUpdate().ActionEvent(responseJSON, webSocket); //??

    responseJSON.put("mapid", oldMapid);
    new PosUpdate().ActionEvent(responseJSON, webSocket); //??        
}

From source file:geo.model.MRTStation.java

public JSONObject getJSONObject() {
    JSONObject obj = new JSONObject();
    try {/*from   ww w. j a v  a  2  s  . co m*/
        obj.put("code", code);
        obj.put("stationName", stationName);
        obj.put("workingName", workingName);
        obj.put("lineCode", lineCode);
        obj.put("stationNumber", stationNumber);
        obj.put("lat", lat);
        obj.put("lng", lng);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return obj;
}

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:ch.newscron.newscronjsp.ShortUrlCreator.java

private JSONObject createJSON(String customerId, String rew1, String rew2, String val) {
    JSONObject obj = new JSONObject();
    obj.put("custID", customerId);
    obj.put("rew1", rew1);
    obj.put("rew2", rew2);
    obj.put("val", val);
    return obj;//from w  w  w. j  a  va 2 s . c o  m
}

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

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

From source file:modelo.ParametrizacionManagers.TipoVisita.java

public JSONArray getTiposVisitas() throws SQLException {
    //Ejecutamos la consulta y obtenemos el ResultSet
    SeleccionarTipoVisita select = new SeleccionarTipoVisita();
    ResultSet rset = select.getTiposVisitas();

    //Creamos los JSONArray para guardar los objetos JSON
    JSONArray jsonArray = new JSONArray();
    JSONArray jsonArreglo = new JSONArray();
    //Recorremos el ResultSet, armamos el objeto JSON con la info y guardamos
    //en el JSONArray.
    while (rset.next()) {

        //Armamos el objeto JSON con la informacion del registro
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("codigo", rset.getString("CODIGO"));
        jsonObject.put("descripcion", rset.getString("DESCRIPCION"));

        //Guardamos el JSONObject en el JSONArray y lo enviamos a la vista.
        jsonArray.add(jsonObject.clone());

    }//from  w w  w.  ja  v  a 2  s .c o m

    jsonArreglo.add(jsonArray);
    select.desconectar();
    return jsonArreglo;
}

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

@SuppressWarnings("unchecked")
@Override/*www  . ja va2 s  .com*/
public HttpEntity createDocument(UserGroup userGroup) {

    LinkedHashMap<String, String> orderedUserGroupMap = new LinkedHashMap<>();
    orderedUserGroupMap.put("title", userGroup.getTitle());
    orderedUserGroupMap.put("permission", userGroup.getPermission().toString());

    JSONArray users = new JSONArray();
    List<User> userGroupUsers = userGroup.getUsers();
    for (User user : userGroupUsers) {
        JSONObject userObject = new JSONObject();
        userObject.put("id", user.getId().toString());
        users.add(userObject);
    }

    JSONObject userGroupObject = new JSONObject(orderedUserGroupMap);
    userGroupObject.put("users", users);

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

From source file:biomine.bmvis2.pipeline.GrouperOperation.java

public JSONObject toJSON() {
    JSONObject ret = new JSONObject();
    ret.put("grouper", this.grouper.getClass().getName());
    return ret;/*  w  ww. j av  a2 s  . c om*/
}