OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 144 | Rev 182 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 144 Rev 180
Line 150... Line 150...
150
    public static <T> T getParameterFromJSON(final JSONObject json, final String key, final Class<T> type) {
150
    public static <T> T getParameterFromJSON(final JSONObject json, final String key, final Class<T> type) {
151
        return getParameterFromJSON(json, key, type, null);
151
        return getParameterFromJSON(json, key, type, null);
152
    }
152
    }
153
 
153
 
154
    public static <T> T getParameterFromJSON(final JSONObject json, final String key, final Class<T> type, T defaultValue) {
154
    public static <T> T getParameterFromJSON(final JSONObject json, final String key, final Class<T> type, T defaultValue) {
-
 
155
        if (json == null) {
-
 
156
            throw new IllegalArgumentException("null JSON");
-
 
157
        }
-
 
158
        if (key == null) {
-
 
159
            throw new IllegalArgumentException("null key");
-
 
160
        }
155
        return json.containsKey(key) ? getObjectFromJSON(json.get(key), type) : defaultValue;
161
        return json.containsKey(key) ? getObjectFromJSON(json.get(key), type) : defaultValue;
156
    }
162
    }
157
 
163
 
158
    public static JSONObject convertStringToJsonObject(final String jsonString) {
164
    public static JSONObject convertStringToJsonObject(final String jsonString) {
159
        final JSONParser parser = new JSONParser(JSONParser.USE_HI_PRECISION_FLOAT);
165
        final JSONParser parser = new JSONParser(JSONParser.USE_HI_PRECISION_FLOAT);