Example usage for org.json.simple JSONObject putAll

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

Introduction

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

Prototype

void putAll(Map<? extends K, ? extends V> m);

Source Link

Document

Copies all of the mappings from the specified map to this map (optional operation).

Usage

From source file:com.p000ison.dev.simpleclans2.util.JSONUtil.java

public static String mapToJSON(Map map) {
    JSONObject JSONMap = new JSONObject();

    JSONMap.putAll(map);

    return JSONMap.toJSONString();
}

From source file:edu.vt.vbi.patric.portlets.DiseaseOverview.java

@SuppressWarnings("unchecked")
public static JSONObject encodeNodeJSONObject(ResultType rt) {

    JSONObject obj = new JSONObject();
    obj.putAll(rt);

    obj.put("id", rt.get("tree_node"));
    obj.put("node", rt.get("tree_node"));
    obj.put("expanded", "true");

    if (rt.get("leaf").equals("1")) {
        obj.put("leaf", "true");
    } else {/* w  w  w.j a  v a  2s .  com*/
        obj.put("leaf", "false");
    }
    return obj;
}

From source file:net.duckling.ddl.web.controller.space.SpaceController.java

@SuppressWarnings("unchecked")
private static void writeResponse(HttpServletResponse response, int state, String message,
        Map<String, Object> params) {
    JSONObject msg = new JSONObject();
    msg.put("state", state);
    msg.put("msg", message);
    if (params != null) {
        msg.putAll(params);
    }//from  w ww.  ja  v a2 s .  c  o  m
    JsonUtil.writeJSONObject(response, msg);
}

From source file:com.couragelabs.logging.GlobalContextSocketAppender.java

/**
 * If you call setGlobalContext with "test" you will receive
 * {"global":"test"} out of this method. Overly clever? I think not! ;-)
 *
 * @return The fully processed global context property, serialized as JSON.
 *//* w  w  w .  jav a 2 s.  c o  m*/
@SuppressWarnings("unchecked")
public String getGlobalContext() {
    if (globalContext != null) {
        JSONObject o = new JSONObject();
        o.putAll(globalContext);
        String globalContextStr = o.toJSONString();
        System.out.println(globalContextStr);
        return globalContextStr;
    }
    return null;
}

From source file:au.org.paperminer.db.PublisherHelper.java

/**
 * Get general Info about a publisher/*from   w ww  .  j  av  a  2  s .  com*/
 * @param id
 * @return info as JSON array using table column names as keys
 * @throws PaperMinerException
 */
public String getInfo(String id) throws PaperMinerException {
    String res = "";
    HashMap<String, String> data = getRecord(id);
    if (data != null) {
        JSONObject obj = new JSONObject();
        obj.putAll(data);
        res = obj.toString();
    }
    return res;
}

From source file:com.flaptor.indextank.api.resources.Search.java

@SuppressWarnings("unchecked")
private void addResult(JSONArray ja, SearchResult result) {
    JSONObject document = new JSONObject();
    document.putAll(result.getFields());
    document.put("docid", result.getDocId());
    document.put("query_relevance_score", result.getScore());
    for (Entry<Integer, Double> entry : result.getVariables().entrySet()) {
        document.put("variable_" + entry.getKey(), entry.getValue());
    }//from   w w w.j a  v a 2 s .co  m
    for (Entry<String, String> entry : result.getCategories().entrySet()) {
        document.put("category_" + entry.getKey(), entry.getValue());
    }
    ja.add(document);
}

From source file:com.opensoc.enrichment.adapters.cif.CIFHbaseAdapter.java

public JSONObject enrich(String metadata) {

    JSONObject output = new JSONObject();
    LOGGER.debug("=======Looking Up For:" + metadata);
    output.putAll(getCIFObject(metadata));

    return output;
}

From source file:com.opensoc.enrichment.adapters.threat.ThreatHbaseAdapter.java

public JSONObject enrich(String metadata) {

    JSONObject output = new JSONObject();
    LOGGER.debug("=======Looking Up For:" + metadata);
    output.putAll(getThreatObject(metadata));

    return output;
}

From source file:io.personium.client.EntitySet.java

/**
 * This method is used for the partial update of user data.
 * @param id ID value of the data//  w  ww. j a v a2  s  . c  o  m
 * @param body Request body to be PUT
 * @param etag ETag value
 * @return Partially updated Entity object
 * @throws DaoException Exception thrown
 */
@SuppressWarnings("unchecked")
public Entity mergeAsEntity(String id, HashMap<String, Object> body, String etag) throws DaoException {
    String url = this.getUrl() + "('" + id + "')";
    IRestAdapter rest = RestAdapterFactory.create(accessor);
    PersoniumResponse res = rest.merge(url, JSONObject.toJSONString(body), etag, RestAdapter.CONTENT_TYPE_JSON);
    JSONObject json = new JSONObject();
    json.putAll(body);
    Entity entity = new Entity(accessor, json);
    entity.setResHeaders(res.getHeaderList());
    return entity;
}

From source file:io.personium.client.EntitySet.java

/**
 * This method is used to update the user data.
 * @param key ID value of the user data//  w  w w  .j av  a2 s.co  m
 * @param body Request body
 * @param etag Etag value
 * @return Entity object that is updated
 * @throws DaoException Exception thrown
 */
@SuppressWarnings("unchecked")
public Entity updateAsEntity(String key, HashMap<String, Object> body, String etag) throws DaoException {
    String escapekey = "'" + Utils.escapeURI(key) + "'";
    String url = this.getUrl() + "(" + escapekey + ")";
    IRestAdapter rest = RestAdapterFactory.create(accessor);
    PersoniumResponse res = rest.put(url, JSONObject.toJSONString(body), etag, RestAdapter.CONTENT_TYPE_JSON);
    JSONObject json = new JSONObject();
    json.putAll(body);
    Entity entity = new Entity(accessor, json);
    entity.setResHeaders(res.getHeaderList());
    return entity;
}