public double getDouble(String key) throws JSONException {
        Object o = get(key);
        if(o==null)  return 0;
        try {
        	if(o instanceof Number){
        		return ((Number)o).doubleValue();
        	}else if(o.toString().length()>0){
        		return Double.valueOf((o.toString()));
        	}else
        		return 0;
        } catch (Exception e) {
            throw new JSONException("JSONObject[" + quote(key) +
                "] is not a number.");
        }
    }