public static DynaBean newDynaBean ( JSONObject jsonObject , JsonConfig jsonConfig ) { Map props = getProperties ( jsonObject ) ; for ( Iterator entries = props . entrySet ( ) . iterator ( ) ; entries . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) entries . next ( ) ; String key = ( String ) entry . getKey ( ) ; if ( ! JSONUtils . isJavaIdentifier ( key ) ) { String parsedKey = JSONUtils . convertToJavaIdentifier ( key , jsonConfig ) ; if ( parsedKey . compareTo ( key ) != 0 ) { props . put ( parsedKey , props . remove ( key ) ) ; } } } MorphDynaClass dynaClass = new MorphDynaClass ( props ) ; MorphDynaBean dynaBean = null ; try { dynaBean = ( MorphDynaBean ) dynaClass . newInstance ( ) ; dynaBean . setDynaBeanClass ( dynaClass ) ; } catch ( Exception e ) { throw new JSONException ( e ) ; } return dynaBean ; }
Creates a new MorphDynaBean from a JSONObject . The MorphDynaBean will have all the properties of the original JSONObject with the most accurate type . Values of properties are not copied .