Example usage for org.json.simple JSONArray addAll

List of usage examples for org.json.simple JSONArray addAll

Introduction

In this page you can find the example usage for org.json.simple JSONArray addAll.

Prototype

public boolean addAll(Collection<? extends E> c) 

Source Link

Document

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's Iterator.

Usage

From source file:cc.sferalabs.libs.telegram.bot.api.types.ReplyKeyboardMarkup.java

/**
 * @param keyboard/*from  w  w w .  j a v  a  2 s. co m*/
 * @return
 */
@SuppressWarnings("unchecked")
private static JSONArray toJsonArray(String[][] keyboard) {
    JSONArray matrix = new JSONArray();
    for (String[] line : keyboard) {
        JSONArray array = new JSONArray();
        array.addAll(Arrays.asList(line));
        matrix.add(array);
    }
    return matrix;
}

From source file:com.p000ison.dev.copybooks.util.Helper.java

public static String fromListToJSONString(String key, List<String> list) {

    JSONObject json = new JSONObject();

    JSONArray array = new JSONArray();
    array.addAll(list);

    json.put(key, array);//  w w  w  .ja  v a 2s.co  m

    return json.toString();
}

From source file:jQuery.PRIMO.Record.java

/**
 * Resolve dedup record string./*from ww  w  .  j  av a2s.c om*/
 *
 * @param dedupID the dedup id
 * @param request the request
 * @return a JSON array of record id's
 */
public static String resolveDedupRecord(String dedupID, HttpServletRequest request) {
    JSONArray obj = new JSONArray();

    try {

        if ((dedupID != null) && (dedupID.length() > 0)) {
            obj.addAll(Helpers.resolveDedupRecord(dedupID, request));
        }
    } catch (Exception e) {
        e.printStackTrace();
        obj.add(e.getMessage());
    }
    return obj.toJSONString();
}

From source file:at.ac.tuwien.dsg.quelle.cloudServicesModel.util.conversions.ConvertToJSON.java

public static String convertToJSON(MultiLevelRequirements multiLevelRequirements) {

    //traverse the tree to do the JSON properly
    List<JSONObject> jsontree = new ArrayList<JSONObject>();
    List<MultiLevelRequirements> multiLevelRequirementsTree = new ArrayList<MultiLevelRequirements>();

    JSONObject root = processMultiLevelRequirementsElement(multiLevelRequirements);

    jsontree.add(root);//from  w ww. ja v a  2s .c om
    multiLevelRequirementsTree.add(multiLevelRequirements);

    //traverse the tree in a DFS manner
    while (!multiLevelRequirementsTree.isEmpty()) {
        MultiLevelRequirements currentlyProcessed = multiLevelRequirementsTree.remove(0);
        JSONObject currentlyProcessedJSONObject = jsontree.remove(0);
        JSONArray childrenArray = new JSONArray();
        //process children
        for (MultiLevelRequirements child : currentlyProcessed.getContainedElements()) {
            JSONObject childJSON = processMultiLevelRequirementsElement(child);
            childrenArray.add(childJSON);

            //next to process are children
            jsontree.add(childJSON);
            multiLevelRequirementsTree.add(child);
        }
        if (currentlyProcessedJSONObject.containsKey("children")) {
            JSONArray array = (JSONArray) currentlyProcessedJSONObject.get("children");
            array.addAll(childrenArray);
        } else {
            currentlyProcessedJSONObject.put("children", childrenArray);
        }
    }

    return root.toJSONString();

}

From source file:hd3gtv.mydmam.web.Privileges.java

public static JSONArray getJSONAllPrivileges() {
    JSONArray ja = new JSONArray();
    ja.addAll(all_privileges);
    return ja;//from   ww w . jav a  2 s  .  c  o m
}

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

public static String collectionToJSON(Collection collection) {
    if (collection == null) {
        return null;
    }//from  w w w.j a va2  s .c om

    JSONArray array = new JSONArray();

    array.addAll(collection);

    return array.toJSONString();
}

From source file:com.doubotis.restwrapper.data.JArray.java

@Override
public String toJSONString() {

    JSONArray jsonArray = new JSONArray();
    jsonArray.addAll(this);
    return jsonArray.toJSONString();
}

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

@Override
@SuppressWarnings("unchecked")
public JSONObject toJSONObject() {
    JSONObject result = super.toJSONObject();
    JSONArray valuesArray = new JSONArray();
    valuesArray.addAll(values);
    result.put("values", valuesArray);
    return result;
}

From source file:logica.Array.java

public JSONArray crearJson(int tipo) {
    JSONArray Json = new JSONArray();
    if (tipo == 0)
        Json.addAll(array);
    else//from  w  w w  .  j  a  v a2  s  .  c o  m
        Json.addAll(arrayPC);
    System.out.println(Json);
    System.out.println(Json.get(1));
    return Json;

}

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

@Override
@SuppressWarnings("unchecked")
public JSONObject toJSONObject() {
    JSONObject result = super.toJSONObject();
    final JSONArray suggestionArray = new JSONArray();
    suggestionArray.addAll(suggestions);
    result.put("suggestions", suggestionArray);
    return result;
}