Search in sources :

Example 1 with OpenProperties

use of com.servoy.j2db.util.OpenProperties in project servoy-client by Servoy.

the class ComponentFactory method parseJSonProperties.

public static <T> Map<String, T> parseJSonProperties(String properties) throws IOException {
    if (properties == null || properties.length() <= 0) {
        return null;
    }
    if (properties.startsWith("{")) {
        // new format: json
        try {
            return new JSONWrapperMap<T>(new ServoyJSONObject(properties, false, true, false));
        } catch (JSONException e) {
            Debug.error(e);
            throw new IOException();
        }
    }
    // old format: OpenProperties
    OpenProperties props = new OpenProperties();
    props.load(new StringReader(properties));
    return (Map<String, T>) props;
}
Also used : ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) OpenProperties(com.servoy.j2db.util.OpenProperties) JSONWrapperMap(com.servoy.j2db.util.JSONWrapperMap) StringReader(java.io.StringReader) JSONException(org.json.JSONException) IOException(java.io.IOException) Map(java.util.Map) JSONWrapperMap(com.servoy.j2db.util.JSONWrapperMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) WeakHashMap(java.util.WeakHashMap)

Aggregations

JSONWrapperMap (com.servoy.j2db.util.JSONWrapperMap)1 OpenProperties (com.servoy.j2db.util.OpenProperties)1 ServoyJSONObject (com.servoy.j2db.util.ServoyJSONObject)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 WeakHashMap (java.util.WeakHashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 JSONException (org.json.JSONException)1