private static JSONObject parseProperties(HashMap<String, String> properties) throws JSONException {
        if (properties != null) {
            JSONObject propertiesObject = new JSONObject();

            for (String key : properties.keySet()) {
                String propertyValue = properties.get(key);

                /*
                 * if(propertyValue.matches("true|false")) {
                 * 
                 * propertiesObject.put(key, propertyValue.equals("true"));
                 * 
                 * } else if(propertyValue.matches("[0-9]+")) {
                 * 
                 * Integer value = Integer.parseInt(propertyValue);
                 * propertiesObject.put(key, value);
                 * 
                 * } else
                 */
                if (propertyValue.startsWith("{") && propertyValue.endsWith("}")) {
                    propertiesObject.put(key,
                                         new JSONObject(propertyValue));
                } else {
                    propertiesObject.put(key,
                                         propertyValue.toString());
                }
            }

            return propertiesObject;
        }

        return new JSONObject();
    }
private static JSONObject parseProperties ( HashMap < String , String > properties ) throws JSONException { if ( properties != null ) { JSONObject propertiesObject = new JSONObject ( ) ; for ( String key : properties . keySet ( ) ) { String propertyValue = properties . get ( key ) ; if ( propertyValue . startsWith ( "{" ) && propertyValue . endsWith ( "}" ) ) { propertiesObject . put ( key , new JSONObject ( propertyValue ) ) ; } else { propertiesObject . put ( key , propertyValue . toString ( ) ) ; } } return propertiesObject ; } return new JSONObject ( ) ; }
Delivers the correct JSON Object for properties

@param properties
@throws org.json.JSONException