private static int readJsonObject(String json, Map<String, Object> object, int startIndex, int len) {
        StringBuilder builder = new StringBuilder();

        String key = null;
        // skip the first bracket
        for (int i = startIndex + 1; i < len; i++) {
            char ch = json.charAt(i);
            if (Character.isWhitespace(ch) || ch == ',' || ch == ':') {
                continue;
            } else if (ch == '"') {
                i = readUnescapedJsonString(json, builder, i, len) - 1;
                if (key != null) {
                    object.put(key, builder.toString());
                    key = null;
                } else {
                    key = builder.toString();
                }
                builder.setLength(0);
            } else if (ch == '-' || (ch >= '0' && ch <= '9')) {
                if (key == null) {
                    throw new IllegalArgumentException("Key is not available");
                }
                List<Object> list = new ArrayList<>(1);
                i = readJsonNumber(json, list, i, len) - 1;
                object.put(key, list.get(0));
                key = null;
                builder.setLength(0);
            } else if (ch == '{') {
                if (key == null) {
                    throw new IllegalArgumentException("Key is not available");
                }
                Map<String, Object> map = new LinkedHashMap<>();
                i = readJsonObject(json, map, i, len) - 1;
                object.put(key, map);
                key = null;
                builder.setLength(0);
            } else if (ch == '[') {
                if (key == null) {
                    throw new IllegalArgumentException("Key is not available");
                }

                List<Object> list = new LinkedList<>();
                i = readJsonArray(json, list, i, len) - 1;
                key = null;
                object.put(key, list.toArray(new Object[0]));
            } else if (ch == '}') {
                return i + 1;
            } else {
                if (key == null) {
                    throw new IllegalArgumentException("Key is not available");
                }
                List<Object> list = new ArrayList<>(1);
                i = readJsonConstants(json, list, i, len) - 1;
                object.put(key, list.get(0));
                key = null;
            }
        }

        return len;
    }
Normalizes given directory by appending back slash if it does exist.

@param dir original directory
@return normalized directory
clickhouse-data/src/main/java/com/clickhouse/data/ClickHouseUtils.java