public static Map<String,Object> toMap(DBObject obj){
        if(obj==null)
            return null;
        Map<String,Object> m = obj.toMap();
        /*if(m.get("_id")!=null) {
            m.put("_id", m.get("_id").toString());
        }*/
        m.remove("_id");

        m = Objects.iterate(m, new Closure<ObjectIterator.IterateBean, Object>() {
            @Override
            public Object call(ObjectIterator.IterateBean input) {
                Object o = input.getValue();
                if(o instanceof Map){
                    Map m = (Map)o;
                    if(m.containsKey("$date") && m.size()==1){
                        o = m.get("$date");
                    }
                    if(m.containsKey("_serializable") && m.size()==1){
                        try {
                            byte [] b = (byte [])m.get("_serializable");
                            ByteArrayInputStream bin = new ByteArrayInputStream(b);
                            ObjectInputStream ois = new ObjectInputStream(bin);
                            o = ois.readObject();
                        } catch (Exception e) {
                            throw S1SystemError.wrap(e);
                        }
                    }
                }
                return o;
            }
        });
        return m;
    }
public static Map < String , Object > toMap ( DBObject obj ) { if ( obj == null ) return null ; Map < String , Object > m = obj . toMap ( ) ; m . remove ( "_id" ) ; m = Objects . iterate ( m , new Closure < ObjectIterator . IterateBean , Object > ( ) { @ Override public Object call ( ObjectIterator . IterateBean input ) { Object o = input . getValue ( ) ; if ( o instanceof Map ) { Map m = ( Map ) o ; if ( m . containsKey ( "$date" ) && m . size ( ) == 1 ) { o = m . get ( "$date" ) ; } if ( m . containsKey ( "_serializable" ) && m . size ( ) == 1 ) { try { byte [ ] b = ( byte [ ] ) m . get ( "_serializable" ) ; ByteArrayInputStream bin = new ByteArrayInputStream ( b ) ; ObjectInputStream ois = new ObjectInputStream ( bin ) ; o = ois . readObject ( ) ; } catch ( Exception e ) { throw S1SystemError . wrap ( e ) ; } } } return o ; } } ) ; return m ; }
@param obj
@return