Search in sources :

Example 36 with JSONObject

use of org.camunda.bpm.engine.impl.util.json.JSONObject in project camunda-bpm-platform by camunda.

the class ModificationBatchConfigurationJsonConverter method readProcessInstanceIds.

protected List<String> readProcessInstanceIds(JSONObject jsonObject) {
    List<Object> objects = JsonUtil.jsonArrayAsList(jsonObject.getJSONArray(PROCESS_INSTANCE_IDS));
    List<String> processInstanceIds = new ArrayList<String>();
    for (Object object : objects) {
        processInstanceIds.add((String) object);
    }
    return processInstanceIds;
}
Also used : ArrayList(java.util.ArrayList) JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject)

Example 37 with JSONObject

use of org.camunda.bpm.engine.impl.util.json.JSONObject in project camunda-bpm-platform by camunda.

the class ModificationBatchConfigurationJsonConverter method toJsonObject.

@Override
public JSONObject toJsonObject(ModificationBatchConfiguration configuration) {
    JSONObject json = new JSONObject();
    JsonUtil.addListField(json, INSTRUCTIONS, ModificationCmdJsonConverter.INSTANCE, configuration.getInstructions());
    JsonUtil.addListField(json, PROCESS_INSTANCE_IDS, configuration.getIds());
    JsonUtil.addField(json, PROCESS_DEFINITION_ID, configuration.getProcessDefinitionId());
    JsonUtil.addField(json, SKIP_LISTENERS, configuration.isSkipCustomListeners());
    JsonUtil.addField(json, SKIP_IO_MAPPINGS, configuration.isSkipIoMappings());
    return json;
}
Also used : JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject)

Example 38 with JSONObject

use of org.camunda.bpm.engine.impl.util.json.JSONObject in project camunda-bpm-platform by camunda.

the class JsonArrayOfObjectsConverter method toJsonArray.

public JSONArray toJsonArray(List<T> objects) {
    JSONArray jsonArray = new JSONArray();
    for (T object : objects) {
        JSONObject jsonObject = objectConverter.toJsonObject(object);
        jsonArray.put(jsonObject);
    }
    return jsonArray;
}
Also used : JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject) JSONArray(org.camunda.bpm.engine.impl.util.json.JSONArray)

Example 39 with JSONObject

use of org.camunda.bpm.engine.impl.util.json.JSONObject in project camunda-bpm-platform by camunda.

the class JsonTaskQueryVariableValueConverter method toJsonObject.

public JSONObject toJsonObject(TaskQueryVariableValue variable) {
    JSONObject json = new JSONObject();
    json.put("name", variable.getName());
    json.put("value", variable.getValue());
    json.put("operator", variable.getOperator());
    return json;
}
Also used : JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject)

Example 40 with JSONObject

use of org.camunda.bpm.engine.impl.util.json.JSONObject in project camunda-bpm-platform by camunda.

the class JsonUtil method jsonObjectAsMap.

/**
 * Converts a {@link JSONObject} to a {@link Map}. It supports nested {@link JSONObject}
 * and {@link JSONArray}.
 *
 * @param jsonObject the json object to convert
 * @return the resulting map
 */
public static Map<String, Object> jsonObjectAsMap(JSONObject jsonObject) {
    if (jsonObject == null) {
        return null;
    } else {
        Map<String, Object> map = new HashMap<String, Object>();
        Iterator keys = jsonObject.keys();
        while (keys.hasNext()) {
            String key = (String) keys.next();
            Object value = optJavaNull(jsonObject.get(key));
            if (JSONObject.class.isInstance(value)) {
                value = jsonObjectAsMap(JSONObject.class.cast(value));
            } else if (JSONArray.class.isInstance(value)) {
                value = jsonArrayAsList(JSONArray.class.cast(value));
            }
            map.put(key, value);
        }
        return map;
    }
}
Also used : HashMap(java.util.HashMap) Iterator(java.util.Iterator) JSONArray(org.camunda.bpm.engine.impl.util.json.JSONArray) JSONObject(org.camunda.bpm.engine.impl.util.json.JSONObject)

Aggregations

JSONObject (org.camunda.bpm.engine.impl.util.json.JSONObject)40 ArrayList (java.util.ArrayList)10 JSONArray (org.camunda.bpm.engine.impl.util.json.JSONArray)5 TaskQueryImpl (org.camunda.bpm.engine.impl.TaskQueryImpl)4 QueryOrderingProperty (org.camunda.bpm.engine.impl.QueryOrderingProperty)3 JsonTaskQueryConverter (org.camunda.bpm.engine.impl.json.JsonTaskQueryConverter)3 QueryProperty (org.camunda.bpm.engine.query.QueryProperty)3 Map (java.util.Map)2 QueryOperator (org.camunda.bpm.engine.impl.QueryOperator)2 Test (org.junit.Test)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Writer (java.io.Writer)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1 HttpPost (org.apache.http.client.methods.HttpPost)1 Direction (org.camunda.bpm.engine.impl.Direction)1 QueryEntityRelationCondition (org.camunda.bpm.engine.impl.QueryEntityRelationCondition)1