Dmitry Parhonin - 2015-12-01

Is this project supported?

Proposed fix for 3.3:

--- ../../Sources/flexjson-3.3/flexjson/ObjectBinder.java (revision )
+++ ../../Sources/flexjson-3.3/flexjson/ObjectBinder.java (revision )
@@ -146,6 +146,7 @@
Type[] types = setMethod.getGenericParameterTypes();
if( types.length == 1 ) {
Type paramType = types[0];

  • value = convertValue(value, descriptor);
    setMethod.invoke( objectStack.getLast(), bind( value, resolveParameterizedTypes( paramType, targetType ) ) );
    } else {
    throw new JSONException(currentPath + ": Expected a single parameter for method " + target.getClass().getName() + "." + setMethod.getName() + " but got " + types.length );
    @@ -154,6 +155,7 @@
    Field field = descriptor.getProperty();
    if( field != null ) {
    field.setAccessible( true );
  • value = convertValue(value, descriptor);
    field.set( target, bind( value, field.getGenericType() ) );
    }
    }
    @@ -169,6 +171,18 @@
    }
    }

  • private Object convertValue(Object value, BeanProperty property) {

  • ObjectFactory factory = null;
  • try {
  • factory = property.getObjectFactory();
  • if (factory != null)
  • value = factory.instantiate(this, value, property.getPropertyType(), property.getPropertyType());
  • } catch(InstantiationException | IllegalAccessException ex){
  • throw new JSONException("Cannot instantiate the property's object factory!", ex);
  • }
  • return value;
  • }
    +
    public JSONException cannotConvertValueToTargetType(Object value, Class targetType) {
    return new JSONException( String.format("%s: Can not convert %s into %s", currentPath, value.getClass().getName(), targetType.getName() ) );
    }
 

Last edit: Dmitry Parhonin 2015-12-03