@Override
    public TaskConfig convertJsonToTaskConfig(String configJson) {
        final TaskConfig taskConfig = new TaskConfig();
        ArrayList<String> exceptions = new ArrayList<>();
        try {
            Map<String, Object> configMap = (Map) GSON.fromJson(configJson, Object.class);
            if (configMap.isEmpty()) {
                exceptions.add("The Json for Task Config cannot be empty");
            }
            for (Map.Entry<String, Object> entry : configMap.entrySet()) {
                TaskConfigProperty property = new TaskConfigProperty(entry.getKey(), null);
                property.with(Property.REQUIRED, true);

                Map propertyValue = (Map) entry.getValue();
                if (propertyValue != null) {
                    if (propertyValue.containsKey("default-value")) {
                        if (!(propertyValue.get("default-value") instanceof String)) {
                            exceptions.add(String.format("Key: '%s' - The Json for Task Config should contain a not-null 'default-value' of type String", entry.getKey()));
                        } else {
                            property.withDefault((String) propertyValue.get("default-value"));
                        }
                    }
                    if (propertyValue.containsKey("display-name")) {
                        if (!(propertyValue.get("display-name") instanceof String)) {
                            exceptions.add(String.format("Key: '%s' - 'display-name' should be of type String", entry.getKey()));
                        } else {
                            property.with(Property.DISPLAY_NAME, (String) propertyValue.get("display-name"));
                        }
                    }
                    if (propertyValue.containsKey("display-order")) {
                        if (!(propertyValue.get("display-order") instanceof String && StringUtil.isInteger((String) propertyValue.get("display-order")))) {
                            exceptions.add(String.format("Key: '%s' - 'display-order' should be a String containing a numerical value", entry.getKey()));
                        } else {
                            property.with(Property.DISPLAY_ORDER, Integer.parseInt((String) propertyValue.get("display-order")));
                        }
                    }
                    if (propertyValue.containsKey("secure")) {
                        if (!(propertyValue.get("secure") instanceof Boolean)) {
                            exceptions.add(String.format("Key: '%s' - The Json for Task Config should contain a 'secure' field of type Boolean", entry.getKey()));
                        } else {
                            property.with(Property.SECURE, (Boolean) propertyValue.get("secure"));
                        }
                    }
                    if (propertyValue.containsKey("required")) {
                        if (!(propertyValue.get("required") instanceof Boolean)) {
                            exceptions.add(String.format("Key: '%s' - The Json for Task Config should contain a 'required' field of type Boolean", entry.getKey()));
                        } else {
                            property.with(Property.REQUIRED, (Boolean) propertyValue.get("required"));
                        }
                    }
                }
                taskConfig.add(property);
            }
            if (!exceptions.isEmpty()) {
                throw new RuntimeException(StringUtils.join(exceptions, ", "));
            }
            return taskConfig;
        } catch (Exception e) {
            LOGGER.error("Error occurred while converting the Json to Task Config. Error: {}. The Json received was '{}'.", e.getMessage(), configJson);
            throw new RuntimeException(String.format("Error occurred while converting the Json to Task Config. Error: %s.", e.getMessage()));
        }
    }
@Test
    public void shouldKeepTheConfigInTheOrderOfDisplayOrder(){
        String json = "{\"URL\":{\"default-value\":\"\",\"secure\":false,\"required\":true,\"display-name\":\"Url\",\"display-order\":\"0\"}," +
                "\"PASSWORD\":{\"display-order\":\"2\"}," +
                "\"USER\":{\"default-value\":\"foo\",\"secure\":true,\"required\":false,\"display-order\":\"1\"}" +
                "}";
        TaskConfig config = new JsonBasedTaskExtensionHandler_V1().convertJsonToTaskConfig(json);
        assertThat(config.list().get(0).getKey(), is("URL"));
        assertThat(config.list().get(1).getKey(), is("USER"));
        assertThat(config.list().get(2).getKey(), is("PASSWORD"));
    }