public static String jsonFromMap(Map<String, Object> jsonData) {
        try {
            JsonDocument json = new JsonDocument();
            json.startGroup();

            for (String key : jsonData.keySet()) {
                Object data = jsonData.get(key);
                if (data instanceof Map) {
                    /* it's a nested map, so we'll recursively add the JSON of this map to the current JSON */
                    json.addLiteralValue(key, jsonFromMap((Map<String, Object>) data));
                } else if (data instanceof Object[]) {
                    /* it's an object array, so we'll iterate the elements and put them all in here */
                    json.addLiteralValue(key, "[" + stringArrayFromObjectArray((Object[]) data) + "]");
                } else if (data instanceof Collection) {
                    /* it's a collection, so we'll iterate the elements and put them all in here */
                    json.addLiteralValue(key, "[" + stringArrayFromObjectArray(((Collection) data).toArray()) + "]");
                } else if (data instanceof int[]) {
                    /* it's an int array, so we'll get the string representation */
                    String intArray = Arrays.toString((int[]) data);
                    /* remove whitespace */
                    intArray = intArray.replaceAll(" ", "");
                    json.addLiteralValue(key, intArray);
                } else if (data instanceof JSONCapableObject) {
                    json.addLiteralValue(key, ((JSONCapableObject) data).getJSON());
                } else {
                    /* all other objects we assume we are to just put the string value in */
                    if (data == null) {
                        json.addValue(key, null);
                    } else {
                        json.addValue(key, data);
                    }
                }
            }

            json.endGroup();

            logger.log(Level.FINER, "created json from map => " + json.toString());
            return json.toString();
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Could not create JSON from Map. ", e);
            return "{}";
        }
    }