*
* @return model array
*/
@SuppressWarnings("unchecked")
public M[] jsonToModels(String json, int maxDepth) {
JsonArrayReader ar = new JsonArrayReader(json, new ModelReader() {
@Override
public <T> T read(JsonReader reader, Class<T> modelClass,
int maxDepth, int currentDepth) {
return invokeJsonToModel(
Datastore.getModelMeta(modelClass),
reader,
maxDepth,
currentDepth + 1);
}
});
M[] ret = (M[]) Array.newInstance(this.getModelClass(), ar.length());
for (int i = 0; i < ar.length(); i++) {
ar.setIndex(i);
ret[i] = jsonToModel(ar.newRootReader(), maxDepth, 0);
}
return ret;
}