public static String mapToString(Map<String,Object> toSend) {
        String key = null;
        Object object = null;
        JsonObjectBuilder dataContainer = Json.createObjectBuilder();
        for(Map.Entry<String,Object> entry: toSend.entrySet()){
            key = entry.getKey();
            object = toSend.get(entry.getKey());
            if( object instanceof String ){
                dataContainer = dataContainer.add(key, (String)object);
            }else if(object instanceof List){
                //start array object
                JsonArrayBuilder arrayObj = Json.createArrayBuilder();
                List items = (List) object;
                for(Object ob : items){
                    if(ob instanceof Map){
                        //start object
                        JsonObjectBuilder insiderArray = Json.createObjectBuilder();
                        JsonObject mapped = mapToJsonObject(((Map) ob).keySet().iterator(),insiderArray,(Map)ob);
                        arrayObj.add(mapped);
                    }else{
                        //String.
                        arrayObj = arrayObj.add((String) ob);
                    }

                }
                dataContainer.add(key, arrayObj);
            }else{
//                System.err.println("[WARN]   Unrecognized object (" + object.getClass() + ") in map in mapToString(...), using .toString()");
                dataContainer = dataContainer.add(key, object.toString());
            }

        }

        return dataContainer.build().toString();
    }