com.daveayan.rjson.transformer.toobject.JsonArrayToVectorTransformer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rjson Show documentation
Show all versions of rjson Show documentation
Recursive, reflection based json to / from object conversion
The newest version!
package com.daveayan.rjson.transformer.toobject;
import java.util.List;
import java.util.Vector;
import com.daveayan.rjson.transformer.JsonToObjectTransformer;
import com.daveayan.json.JSONArray;
import com.daveayan.mirage.ReflectionUtils;
import com.daveayan.transformers.Context;
public class JsonArrayToVectorTransformer implements JsonToObjectTransformer {
public boolean canTransform(Object from, Class> to, String fieldName, Context context) {
if(from == null) { return false; }
if (from instanceof JSONArray) {
if (ReflectionUtils.classImplements(to, Vector.class)) {
return true;
}
}
return false;
}
public Object transform(Object from, Class> to, String fieldName, Context context) {
JSONArray ja = (JSONArray) from;
List